def main():
    n, m = map(int, input().split())

    d = [-1] * (n + 1)
    for _ in range(m):
        s, c = map(int, input().split())
        if d[s] == -1:
            d[s] = c
        elif d[s] != c:
            print(-1)
            return

    if d[1] == 0:
        print(-1)
        return

    ret = ''
    for i in range(1, n + 1):
        if d[i] == -1:
            if i == 1:
                ret += '1'
            else:
                ret += '0'
        else:
            ret += str(d[i])

    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
