#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> a(n, false);
  vector<int> b(n);
  b[0] = 1;
  for (int i = (1); i < (n); i++) b[i] = 0;
  bool ans = true;
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (a[s]) {
      if (b[s] != c) {
        ans = false;
        break;
      }
    } else {
      if (s == 0 && c == 0) {
        ans = false;
        break;
      }
      a[s] = true;
      b[s] = c;
    }
  }
  if (ans) {
    for (int i = 0; i < (n); i++) {
      cout << b[i];
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
