#include <bits/stdc++.h>
using namespace std;
template <typename T>
void debug(T& obj) {}
template <typename T>
T in() {
  T val;
  cin >> val;
  return val;
}
template <typename T>
vector<T> inv(long long num) {
  vector<T> val(num);
  for (long long i = 0; i < num; i++) cin >> val[i];
  return val;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n, -1);
  bool flag = true;
  for (long long i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (vec[s - 1] == -1)
      vec[s - 1] = c;
    else if (vec[s - 1] != c) {
      flag = false;
      break;
    }
  }
  if (flag == false) {
    cout << -1;
  } else {
    if (vec[0] == 0)
      cout << -1;
    else {
      for (long long i = 0; i < n; i++) {
        if (vec[i] != -1)
          cout << vec[i];
        else if (i == 0)
          cout << 1;
        else
          cout << 0;
      }
    }
  }
}
int main(int argc, char* argv[]) {
  solve();
  return 0;
}
