#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int n, m;
vector<int> v;
void solve() {
  cin >> n >> m;
  v.resize(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (v[s - 1] == -1)
      v[s - 1] = c;
    else if (v[s - 1] != c) {
      cout << -1 << endl;
      return;
    }
  }
  if (v[0] == 0) {
    cout << -1 << endl;
    return;
  }
  for (int i = 0; i < n; i++) {
    if (v[0] == -1 && i == 0)
      cout << 1 << "";
    else if (v[i] == -1)
      cout << 0 << "";
    else
      cout << v[i] << "";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}
