import fileinput
import sys

nodata = 0;             
nodata_max=-1;          
nodata_maxline=[];      

tot_file = 0            
num_file = 0            

infiles = sys.argv[1:]

for line in fileinput.input():
  tot_line=0;             
  num_line=0;             

  
  field = line.split()
  date  = field[0]
  data  = [float(f) for f in field[1::2]]
  flags = [int(f)   for f in field[2::2]]

  for datum, flag in zip(data, flags):
    if flag<1:
      nodata += 1
    else:
      
      if nodata_max==nodata and nodata>0:
        nodata_maxline.append(date)
      if nodata_max<nodata and nodata>0:
        nodata_max=nodata
        nodata_maxline=[date]
      
      nodata=0; 
      
      tot_line += datum
      num_line += 1

  
  tot_file += tot_line
  num_file += num_line

  print % (
        date, 
        len(data) -num_line, 
        num_line, tot_line, 
        tot_line/num_line if (num_line>0) else 0)

print 
print % (.join(infiles),)
print % (tot_file,)
print % (num_file,)
print % (tot_file / num_file,)

print % (
    nodata_max, .join(nodata_maxline))