#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m;
vector<int> ans;
vector<int> chn;
int main() {
  cin >> n >> m;
  ans.resize(n, 0);
  chn.resize(n, 0);
  ans[0] = 1;
  int s, c;
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> s >> c;
    if (s > n || (s == 1 && c == 0) || (chn[s - 1] == 1 && ans[s - 1] != c)) {
      cout << "-1" << endl;
      return 0;
    }
    chn[s - 1] = 1;
    ans[s - 1] = c;
  }
  for (long long i = 0; i < (long long)(n); i++) cout << ans[i];
  cout << endl;
  return 0;
}
