#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  pair<int, char> p[100];
  char c[3] = {'0', '0', '0'};
  cin >> n >> m;
  if (m == 0) {
    if (n != 1) {
      if (n == 3) {
        cout << "100" << endl;
      } else if (n == 2) {
        cout << "10" << endl;
      }
      return 0;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p + m);
  for (int j = 0; j < m; j++) {
    if (p[j].first == p[j + 1].first) {
      if (p[j].second != p[j + 1].second) {
        cout << "-1" << endl;
        return 0;
      }
    }
    if (p[j].first == 1 && p[j].second == '0') {
      if (n != 1) {
        cout << "-1" << endl;
        return 0;
      }
    }
    c[p[j].first - 1] = p[j].second;
  }
  if (c[0] == '0') {
    c[0] = '1';
  }
  for (int k = 0; k < n; k++) {
    cout << c[k];
  }
  cout << endl;
  return 0;
}
