#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
int main() {
  int n, m, d[4];
  cin >> n >> m;
  for (int i = 0; i < n; i++) d[i] = -1;
  int s, c;
  bool valid = true;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (d[s - 1] != -1 && d[s - 1] != c) {
      valid = false;
      break;
    }
    d[s - 1] = c;
  }
  if (n > 1 && d[0] == 0) valid = false;
  for (int i = 0; i < n; i++)
    if (d[i] == -1) d[i] = 1;
  if (valid) {
    for (int i = 0; i < n; i++) cout << d[i];
    cout << '\n';
  } else
    cout << -1 << '\n';
}
