def Ucitajvrednost(a, b, c):
a, b = [int(i) for i in input().split()]
if a <= 0 or b <= 0:
quit()
c = [int(i) for i in input().split()]
return a, b, c
def Igra(a, b, c, polje):
pomoc = [0] * b
dobro = 0
loop = 0
for i in c:
if(pomoc[i - 1] == vrsta or i > kolona or i <=0):
dobro=-1
break
else:
polje[a - 1 - pomoc[i - 1]][i-1] = 1
pomoc[i-1]= pomoc[i-1] + 1
return dobro, polje
def Ispis(a, b, c):
for i in range(c):
print(*b[i])
print(a)
vrsta = 0
kolona = 0
potezi = []
status = 0
vrsta, kolona, potezi = Ucitajvrednost(vrsta, kolona, potezi)
p =[]
for i in range(kolona):
p.append(0)
matrica = []
for i in range(vrsta):
p = []
for j in range(kolona):
p.append(0)
matrica.append(p)
status, matrica = Igra(vrsta, kolona, potezi, matrica)
Ispis(status, matrica, vrsta)
ZGVmIFVjaXRhanZyZWRub3N0KGEsIGIsIGMpOgoJYSwgYiA9IFtpbnQoaSkgZm9yIGkgaW4gaW5wdXQoKS5zcGxpdCgpXQoJaWYgYSA8PSAwIG9yIGIgPD0gMDoKCQlxdWl0KCkKCWMgPSBbaW50KGkpIGZvciBpIGluIGlucHV0KCkuc3BsaXQoKV0KCXJldHVybiBhLCBiLCBjCmRlZiBJZ3JhKGEsIGIsIGMsIHBvbGplKToKCXBvbW9jID0gWzBdICogYgoJZG9icm8gPSAwCglsb29wID0gMAoJZm9yIGkgaW4gYzoKCQlpZihwb21vY1tpIC0gMV0gPT0gdnJzdGEgb3IgaSA+IGtvbG9uYSBvciBpIDw9MCk6CgkJCWRvYnJvPS0xCgkJCWJyZWFrCgkJZWxzZToKCQkJCgkJCXBvbGplW2EgLSAxIC0gcG9tb2NbaSAtIDFdXVtpLTFdID0gMQoJCQlwb21vY1tpLTFdPSBwb21vY1tpLTFdICsgMQoJCQkKCXJldHVybiBkb2JybywgcG9samUKZGVmIElzcGlzKGEsIGIsIGMpOgoJZm9yIGkgaW4gcmFuZ2UoYyk6CgkJcHJpbnQoKmJ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