# C - Guess The Number
n, m = map(int, input().split())

a = 0

flg100 = True
flg10 = True
flg1 = True
for i in range(0, m):
    s, c = map(int, input().split())

    if s == 1 and flg100:
        a += c * 100
        flg100 = False
    if s == 2 and flg10:
        a += c * 10
        flg10 = False
    if s == 3 and flg1:
        a += c
        flg1 = False

if 10**(n-1) > a:
    print(-1)
else:
    print(a)
