#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<P> dig;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    dig.emplace_back(n - s, c);
  }
  sort(dig.begin(), dig.end());
  int ans[n];
  for (int i = 0; i < n; ++i) ans[i] = -1;
  for (P p : dig) {
    if (ans[p.first] != -1 && p.second != ans[p.first]) {
      cout << "-1" << endl;
      return 0;
    }
    if (p.first == n - 1 && p.second == 0 && n > 1) {
      cout << "-1" << endl;
      return 0;
    }
    ans[p.first] = p.second;
  }
  for (int i = 0; i < n; ++i) {
    if (ans[i] == -1) {
      if (i == n - 1) {
        ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[n - i - 1];
  }
  cout << endl;
}
