#include <bits/stdc++.h>
using namespace std;
long long INF = 1LL << 60;
long long mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, 0);
  ans[0] = 1;
  for (long long i = 0; i < (long long)(m); ++i) {
    int s, c;
    cin >> s >> c;
    if (ans[i] != 0 && ans[i] != c) {
      cout << -1 << endl;
      return 0;
    } else
      ans[s - 1] = c;
  }
  for (long long i = 0; i < (long long)(n); ++i) {
    cout << ans[i];
  }
  cout << endl;
}
