import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    kaburi_flag = False
    digit = [-1] * N
    for _ in range(M):
        S, C = map(int, input().split())
        if digit[S - 1] == -1:
            digit[S - 1] = C
        else:
            if not(digit[S - 1] == C):
                kaburi_flag = True
    if kaburi_flag or digit[0] == 0:
        print("-1")
    else:
        ans = 0
        for i in range(N):
            if digit[i] == -1:
                if i == 0:
                    ans += 100
            else:
                ans += digit[i] * 10**(N - i - 1)
        print(ans)

if __name__ == "__main__":
    main()