import numpy as np
n,m = map(int,input().split())
if m == 0:
    print(0)
    exit()
if (m == 0 and n == 2) or (m == 0 and n == 3):
    print(-1)
    exit()
c = [[int(j) for j in input().split()] for i in range(m)]
c = sorted(c)
c = np.array(c)
ans = '1' * (c[0][0] - 1)
tmp1 = 0
tmp2 = 0

for i,j in zip(c[:,0],c[:,1]):

    if i == tmp1 and j == tmp2:
        continue
    if i == tmp1 and j != tmp2:
        print(-1)
        exit()
    if i == 1 and j == 0 and n != 1:
        print(-1)
        exit()
    if not tmp1 == 0 and tmp2 == 0:
        ans = ans + '0' * (i - tmp1 - 1)
    print(ans)
    for k in range(10):
        if j == k:
            ans = ans + str(j)
            break
    tmp1 = i
    tmp2 = j
    
print(ans)