import sys
input = sys.stdin.readline
from collections import deque

def main():

    N, M = map(int, input().split())
    Set = []
    for i in range(M):
        Set.append(list(map(int, input().split())))

    for i in range(10**(N-1),10**N):
        num = str(i)
        if all(num[s-1]==str(c) for s,c in Set):
            print(i)
            break
    else:
        print(-1)


if __name__ == '__main__':
    main()