#!/usr/bin/env python3
n, m = map(int, input().split())
s = [-1 for _ in range(m)]
c = [-1 for _ in range(m)]
for i in range(m):
    s[i], c[i] = map(int, input().split())

for i in range(1000):
    flg = True
    numstr = str(i)

    if m == 0:
        print(int(10**(n-1)))
        exit(0)

    # 全条件クリアしたら、その数が答え。
    if len(s) == 0:
        print(0)
        exit(0)

    if len(numstr) != n:
        continue

    for j in range(m):
#        print('numstr =', numstr)
#        print('j =', j)
#        print('numstr[s[j]-1] =', numstr[s[j]-1])
#        print('c[j] =', c[j])
#        print()
        if numstr[s[j]-1] != str(c[j]):
            flg = False
    if flg == True:
        print(i)
        exit(0)
print(-1)
