import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Num = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        if Num[s-1] == -1: 
            if N != 1 and s == 1 and c == 0:
                print(-1)
                break
            else: Num[s-1] = c
        else:
            if Num[s-1] != c:
                print(-1)
                break
    else:
        for i in range(N):
            if Num[i] == -1:
                if i == 0: Num[i] = 1
                else: Num[i] = 0
        print("".join(map(str, Num)))

    return 0

if __name__ =="__main__":
    solve()