def solve():
    n, m = [int(i) for i in input().split()]

    s = [-1 for _ in range(m)]
    c = [-1 for _ in range(m)]

    for i in range(m):
        s[i], c[i] = [int(j) for j in input().split()]

    a = [-1 for _ in range(n)]

    for _s, _c in zip(s, c):
        if a[_s - 1] == -1:
            a[_s - 1] = _c

        elif a[_s - 1] != _c:
            print(-1)
            return
    
    if a[0] == -1:
        a[0] = 1

    for i in range(len(a)):
        if a[i] == -1:
            a[i] = 0
    
    if a[0] == 0 and n != 1:
        print(-1)
        return

    char_a = [str(_a) for _a in a]
    str_a = "".join(char_a)
    print(str_a)

if __name__ == "__main__":
    solve()
