# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque


def main():
    N, M = map(int, input().split())

    digit = [-1] * N

    for i in range(M):
        s, c = map(int, input().split())
        s -= 1
        if digit[s] >= 0 and digit[s] != c:
            print(-1)
            exit()
        digit[s] = c

    if digit[0] == 0:
        print(-1)
        exit()
    if digit[0] < 0:
        digit[0] = 1

    for i in range(N):
        if digit[i] < 0:
            digit[i] = 0

    #    print(digit)
    print("".join(map(str, digit)))


if __name__ == "__main__":
    main()
