Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim N As Integer = CInt(tmp(0))
        Dim M As Integer = CInt(tmp(1))
        Dim wk(N) As String

        For i As Integer = 0 To M - 1
            Dim tp As String() = Split(Console.ReadLine(), " ")
            Dim s As String = tp(0)
            Dim c As String = tp(1)

            If s = 1 AndAlso c = 0 AndAlso N > 1 Then
                Console.WriteLine("-1")
                Exit Sub
            End If

            If wk(CInt(s) - 1) <> Nothing AndAlso wk(CInt(s) - 1) <> c Then
                Console.WriteLine("-1")
                Exit Sub
            End If

            wk(CInt(s) - 1) = c

        Next

        For j As Integer = 0 To N - 1
            Console.Write(If(wk(j) = Nothing, "0", wk(j)))
        Next
        Console.WriteLine()

    End Sub

End Module
