n,m=gets.split.map &:to_i x={} y={} m.times{ b=gets.split.map(&:to_i) c=b[0] x[c]=[] unless x[c] x[c]<0 print 1 y[v].each{|i| x[i].delete v } if y[v] f=true elsif f print 0 end } puts ""