#include <bits/stdc++.h>
using namespace std;
long long inf = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i].first >> p[i].second;
    if (n >= 2 && p[i].first == 1 && p[i].second == 0) {
      cout << "0" << endl;
      return 0;
    }
  }
  vector<long long> number(n, -1);
  for (int i = 0; i < m; i++) {
    if (number[p[i].first - 1] == -1) {
      number[p[i].first - 1] = p[i].second;
    } else {
      if (p[i].second != number[p[i].first - 1]) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == 0 && number[i] == -1) {
      number[i] = 1;
    } else if (number[i] == -1) {
      number[i] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << number[i];
  }
  cout << endl;
}
