#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > digit;
  pair<int, int> temp;
  for (int i = 0; i < (int)(M); i++) {
    cin >> temp.first >> temp.second;
    digit.emplace_back(temp);
  }
  vector<int> ans(N, -1);
  for (int i = 0; i < (int)(M); i++) {
    if (ans[digit[i].first - 1] == -1) {
      ans[digit[i].first - 1] = digit[i].second;
    } else {
      if (ans[digit[i].first - 1] != digit[i].second) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  } else if (ans[0] == -1) {
    ans[0] = 1;
  } else {
    for (int i = 0; i < (int)(N - 1); i++) {
      if (ans[i + 1] == -1) {
        ans[i + 1] = 0;
      }
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}
