def main():
    n, m = map(int, input().split())
    ans = [0] * n
    count = [0] * n
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            print(-1)
            exit()
        if count[s - 1] == 0:
            ans[s - 1] = c
            count[s - 1] += 1
        else:
            print(-1)
            exit()
    if ans[0] == 0:
        ans[0] = 1
    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()
