from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    result = ['*'] * N
    for i in range(M):
        s, c = [int(x) for x in stdin.readline().rstrip().split()]
        if result[s - 1] == '*' or result[s - 1] == str(c):
            result[s - 1] = str(c)
        else:
            print(-1)
            return
    if result[0] == '0' and N != 1:
        print(-1)
        return
    if result[0] == '*':
        result[0] = '1'
    for i in range(N):
        if result[i] == '*':
            result[i] = '0'
    print(''.join(result))


if __name__ == "__main__":
    main()
