#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  if (m != 0) {
    vector<int> v(n);
    v[0] = 1;
    bool ok = true;
    vector<pair<int, int>> pa(m);
    for (int i = 0; i < m; i++) {
      cin >> pa[i].first >> pa[i].second;
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < m; j++) {
        if (pa[i].first == pa[j].first && pa[i].second != pa[j].second) {
          ok = false;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (pa[i].first == 1 && pa[i].second == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      for (int i = 0; i < m; i++) {
        v[pa[i].first - 1] = pa[i].second;
      }
      for (int i = 0; i < n; i++) cout << v[i];
    } else
      cout << -1;
  } else {
    cout << 1;
    for (int i = 0; i < n - 1; i++) cout << 0;
  }
  return 0;
}
