n, m = map(int, input().split())
num = ['x'] * n
flag = 0

if n == 1:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
        else:
            if num[s-1] != c:
                print(-1)
                break
        print(num[s-1])

else:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
            if s == 1 and c == 0:
                print(-1)
                flag = 1
                break
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        for j in range(n):
            if num[0] == 'x':
                num[0] = 1
            else:
                if num[j] == 'x':
                    num[j] = 0
        str_num = map(str, num)
        print(''.join(str_num))