#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int b[6];
  for (int i = 0; i < (int)(6); i++) b[i] = -1;
  if (m == 0) {
    int f = 0;
    for (int i = 1; i <= n; i++) {
      if (b[i] != -1) {
        f = 1;
        cout << b[i];
      } else if (f == 0) {
        cout << 1;
        f = 1;
      } else if (f == 1)
        cout << 0;
    }
    cout << endl;
    return 0;
  }
  vector<pair<int, int>> a(m);
  for (int i = 0; i < (int)(m); i++) cin >> a.at(i).first >> a.at(i).second;
  sort((a).begin(), (a).end());
  b[a.at(0).first] = a.at(0).second;
  for (int i = 1; i < m; i++) {
    if (a.at(i - 1).first == a.at(i).first) {
      if (a.at(i - 1).second != a.at(i).second) {
        cout << -1 << endl;
        return 0;
      } else {
        continue;
      }
    }
    b[a.at(i).first] = a.at(i).second;
  }
  if (n != 1 && b[1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (n == 1 && b[1] == 0) {
    cout << 0 << endl;
    return 0;
  }
  int f = 0;
  for (int i = 1; i <= n; i++) {
    if (b[i] != -1) {
      f = 1;
      cout << b[i];
    } else if (f == 0) {
      cout << 1;
      f = 1;
    } else if (f == 1)
      cout << 0;
  }
  cout << endl;
  return 0;
}
