First working verison.  Assumes all inputs are sorted and does not do RG, PG or SQ merging assuming they all match first input file.