Module C
    Sub Main(ByVal args() As String)
        Dim arr() As String = Split(Console.ReadLine())
        Dim i, total_keta, cnt, keta As Integer
        Dim atai As String
        total_keta = arr(0) : cnt = arr(1)
        Dim dummy(total_keta - 1) As Char
        For i = 0 To total_keta - 1
            dummy(i) = "0"
        Next
        For i = 1 To cnt
            arr = Split(Console.ReadLine())
            keta = arr(0) : atai = arr(1)
            If dummy(keta - 1) = "0" Then
                dummy(keta - 1) = atai
            Else
                If dummy(keta - 1) <> atai Then
                    Console.WriteLine("-1")
                    Return
                End If
            End If
        Next
        If dummy(0) = "0" Then
            Console.WriteLine("-1")
        Else
            Console.WriteLine(Convert.ToString(dummy))
        End If
    End Sub
End Module