#n = int(input())
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)

if n == 1:
    print(0)
    exit()
if m == 0:
    print(-1)
s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]
print(L,s)
if s[0] == 0:
    print(-1)
    exit()

for i in range(1,m):
    if s[i]==-1:
        s[i] = 0
    print(s)
ans = ""
for i in range(m):
    ans += str(s[i])
print(int(ans))