N, M = map(int, input().split())
M_list = [list(map(int, input().split())) for _ in range(M)]


ans = ['#' for _ in range(N)]
flg = False
# 値重複チェック
for m in M_list:
    if ans[m[0]-1]=='#' or ans[m[0]-1]==m[1]:
        ans[m[0]-1] = m[1]
    else:
        flg = True
        break


# 0パディングチェック
if ~flg:
    if ans[0]==0:
        flg = True
    if ans[0]=='#':
        ans[0] = 1
    ans = [i if i !='#' else 0 for i in ans]

if ~flg:
    ans = ''.join([str(i) for i in ans])
    print(ans)
else:
    print(-1)