# -*- coding: utf-8 -*-
def main():
    N, M =  [int(i) for i in input().split()]

    S = []
    for i in range(M):
        S.append([int(i) for i in input().split()])

    answer = "0" * N
    if N != 1 and [1, 0] in S:
        print(-1)
        return

    for s in S:
        if answer[int(s[0])-1] == "0":
            answer = answer[:int(s[0])-1] + str(s[1]) + answer[int(s[0]):]
            #print(answer)
        elif answer[int(s[0])-1] != str(s[1]):
            #print(answer)
            print(-1)
            return
        else:
            continue

    if answer[0] == "0":
        print("1" + answer[1:])
    else:
        print(answer)

if __name__ == "__main__":
    main()
