if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = [99] * n

    for i in range(m):
        s, c = list(map(int, input().split(" ")))
        if a[s - 1] == 99 or a[s - 1] == c:
            a[s - 1] = c
        else:
            print('-1')
            exit()

    # print(a)

    st = ""
    index = 0
    for j in a:
        if j == 99:
            if index == 0:
                st = st + "1"
            else:
                st = st + "0"
        else:
            st = st + str(j)
        index = index + 1

    if st[0] == '0':
         print('-1')
         exit()

    print(int(st))