open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let [| N; M |] = reada int
    let scs = SortedDictionary<int, int>()
    let mutable ok = true
    for i in 0 .. M - 1 do
        let [| s; c |] = reada int
        let s = s - 1
        match scs.ContainsKey(s) with
        | true ->
            if scs.[s] <> c then ok <- false
        | _ -> scs.Add(s, c)

    if scs.ContainsKey(0) && scs.[0] = 0 && N > 1 then ok <- false
    let mutable ans = Array.init N (fun _ -> -1)
    for kv in scs do
        let s, c = kv.Key, kv.Value
        ans.[s] <- c
    for i in 0 .. N - 1 do
        if i = 0 && ans.[i] = -1 then ans.[i] <- 1
        if i > 0 && ans.[i] = -1 then ans.[i] <- 0

    if ok then String.Join("", ans) else "-1"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()
