#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    (N, M) = map(int, inp.readline().strip().split(' '))
    SC = [map(int, inp.readline().strip().split(' ')) for i in range(M)]

    s2c = {}
    for (s, c) in SC:
        if s in s2c and s2c[s] != c:
            return "-1"
        s2c[s] = c

    r = ''
    for i in range(1, N + 1):
        if i in s2c:
            r += str(s2c[i])
        else:
            if i == 1:
                r += '1'
            else:
                r += '0'

    if len(str(int(r))) != N:
        return "-1"

    return r


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()
