n, m = map(int, input().split())
sc_dict = {}
for i in range(m):
    si, ci = map(int, input().split())
    if not si in sc_dict.keys():
        sc_dict[si] = [ci]
    elif not ci in sc_dict[si]:
        sc_dict[si].append(ci)

flag = 0
for k, v in sc_dict.items():
    if len(v) >= 2:
        flag = 1
        break
    if n != 1 and k == 1 and 0 in v:
        flag = 1
        break

if flag:
    print(-1)
else:
    res = ''
    for i in range(n):
        if i+1 in sc_dict.keys():
            res += str(sc_dict[i+1][0])
        elif i == 0:
            res += '1'
        else:
            res += '0'
    print(res)