#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using C = complex<double>;
const double PI = 3.14159265;
const double eps = 1e-8;
const int N = 1e6 + 10;
const int M = 1e9 + 7;
const int inf = 1e9 + 7;
const ll INF = 1e18;
ll pw(ll a, ll b) {
  ll t = 1;
  a %= M;
  for (; b; b >>= 1) {
    if (b & 1) {
      t = t * a % M;
    }
    a = a * a % M;
  }
  return t;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    if (a[x] == -1) {
      a[x] = y;
    } else if (a[x] != y) {
      cout << "-1\n";
      return 0;
    }
  }
  if (a[0] == 0) {
    if (n == 1) {
      cout << "0\n";
    } else {
      cout << "-1\n";
    }
    return 0;
  }
  if (a[0] == -1) {
    a[0] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == -1) {
      a[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i];
  }
  puts("");
}
