#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int sz = 500;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > vec(m);
  string ans = "";
  ans.append(n, 'a');
  for (int i = 0; i < m; i++) {
    cin >> vec[i].first >> vec[i].second;
    vec[i].first--;
  }
  sort(vec.begin(), vec.end());
  bool flag = true;
  for (int i = 1; i < m; i++) {
    if (vec[i].first == vec[i - 1].first &&
        vec[i].second != vec[i - 1].second) {
      flag = false;
    }
  }
  for (auto x : vec) {
    ans[x.first] = (x.second + '0');
  }
  if (ans[0] == 'a') ans[0] = '1';
  for (int i = 1; i < m; i++) {
    if (ans[i] == 'a') ans[i] = '0';
  }
  if (!flag || ans[0] == '0')
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
