def main():

    N, M = map(int, input().split())
    ans = "1" + "0" * (N-1)
    visited = set()
    d= dict()
    for i in range(M):
        s, c = map(int, input().split())
        if s in d and d[s] != c: return -1
        if s == 1 and c == 0: return -1
        d[s] = c

    for s in d:
        ans = ans[:s-1] + str(d[s]) + ans[s:]
    return int(ans)

if __name__ == '__main__':
    print(main())
