#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001000;
const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N, 0);
  ans[0] = inf;
  for (int i = 0; i < M; ++i) {
    int p, t;
    cin >> p >> t;
    if (ans[p - 1] != inf && ans[p - 1] != 0 && ans[p - 1] != t) {
      cout << -1 << endl;
      return 0;
    }
    ans[p - 1] = t;
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (ans[0] == inf) ans[0] = 1;
  for (int i = 0; i < N; ++i) cout << ans[i];
  cout << endl;
  return 0;
}
