import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *SC = map(int, read().split())

    A = [-1] * N
    for s, c in zip(*[iter(SC)] * 2):
        s -= 1
        if A[s] != -1 and A[s] != c:
            print(-1)
            return
        else:
            A[s] = c

    if N > 1 and A[0] == 0:
        print(-1)
        return
    elif A[0] == -1:
        A[0] = 1

    for i in range(1, N):
        if A[i] == -1:
            A[i] = 0

    ans = ''.join(map(str, A))

    print(ans)
    return


if __name__ == '__main__':
    main()
