package main

import (
        "fmt"
)

func solution(n, m int, matrix [][]int) int {
        if m == 0 {
                return e(3 - n)
        }
        nums := make([]int, n)
        for i := range matrix {
                s := matrix[i][0]
                c := matrix[i][1]
                nums[s-1] = c
        }

        if nums[0] == 0 && n != 1 {
                return -1
        }
        var ans int
        for s, c := range nums {
                ans += e(s) * c
        }
        return ans
}

func e(i int) int {
        var ans int

        switch {
        case i == 2:
                ans = 1
        case i == 1:
                ans = 10
        case i == 0:
                ans = 100
        }
        return ans
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        matrix := make([][]int, m)

        for i := 0; i < m; i++ {
                var s, c int
                fmt.Scan(&s, &c)
                matrix[i] = []int{s, c}
        }
        fmt.Println(solution(n, m, matrix))
}