import sys
n,m = map(int,input().split())
num_list = ["a"]
for i in range(n-1):
    num_list.append("a")
for i in range(m):
    s,c = map(int,input().split())
    if num_list[s-1] == "a":
        num_list[s-1] = c
    elif num_list[s-1] == c:
        pass
    else:
        print(1)
        sys.exit()
ret_num = 0
for i in range(n):
    if num_list[i] == "a":
        if i == 0:
            num_list[i] = 1
        else:
            num_list[i] = 0
    ret_num += 10**(n-i-1)*num_list[i]

print(ret_num)