def main():
    n, m = map(int, input().split())

    d = [-1] * n
    for _ in range(m):
        it = map(int, input().split())
        s = next(it) - 1
        c = next(it)
        if ~d[s] and d[s] != c:  # d[s]は代入済かつcではない
            print(-1)
            return
        d[s] = c

    if n != 1 and d[0] == 0:
        print(-1)
        return

    def gen():
        curr = 0
        while curr < n:
            if ~d[curr]:  # 代入済
                yield d[curr]
            else:
                if curr == 0:
                    yield 1
                else:
                    yield 0
            curr += 1

    print(*gen(), sep='')


if __name__ == '__main__':
    main()
