#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const long long inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    c[i] = 10;
  }
  bool check = false;
  for (int i = 0; i < m; i++) {
    int si, ci;
    cin >> si >> ci;
    if (c[si - 1] != 10)
      check = true;
    else
      c[si - 1] = ci;
  }
  if (c[0] == 0 || c[0] == 10 || check)
    cout << -1;
  else {
    for (int i = 0; i < n; i++) {
      if (c[i] > 9)
        cout << 0;
      else
        cout << c[i];
    }
  }
}
