#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vc;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    vc.push_back(make_pair(x, y));
  }
  sort(vc.begin(), vc.end());
  if (m == 0) {
    if (n == 1)
      cout << 0;
    else if (n == 2)
      cout << 10;
    else
      cout << 100;
  }
  for (int i = 0; i + 1 < vc.size(); i++) {
    if (vc[i].first == vc[i + 1].first && vc[i].second != vc[i + 1].second) {
      cout << -1;
      return 0;
    }
    if (vc[i].first == 1 && vc[i].second == 0) {
      cout << -1;
      return 0;
    }
  }
  int k = 1;
  for (int i = 0; i < vc.size(); i++) {
    if (vc[i].first == k) {
      cout << vc[i].second;
      k++;
    } else if (k == 1) {
      cout << 1;
      k++;
    } else {
      cout << 0;
      k++;
    }
  }
  return 0;
}
