import sys
from math import factorial


def main(S):
    pass


if __name__ == '__main__':
    n, m = map(int, input().split())

    B = [-1] * n

    ans = 1
    for i in range(m):
        s, c = map(int, input().split())
        if (B[s - 1] == -1):
            B[s - 1] = c
        elif (B[s - 1] != c):
            ans = 0
            break

    if (B[0] == -1):
        B[0] = 1
    if (B[0] == 0):
        ans = 0

    for i in range(1, n):
        if (B[i] == -1):
            B[i] = 0
    if ans == 0:
        print(-1)
    else:
        S = ""
        for i in range(n):
            S += str(B[i])
        print(S)
