def main():
    N, M = map(int, input().split())
    d = [None for _ in range(N)]
    for _ in range(M):
        s, c = map(int, input().split())
        if d[s-1] is not None and d[s-1] != c:
            print("-1")
            exit()
        elif N > 1 and s == 1 and c == 0:
            print("-1")
            exit()
        else:
            d[s-1] = c

    ans = ""
    for idx, v in enumerate(d):
        if v is not None:
            ans += str(v)
        elif idx == 0 and v is None:
            ans += "1"
        else:
            ans += "0"
    print(ans)


if __name__ == '__main__':
    main()
