#include <bits/stdc++.h>
using namespace std;
template <class T>
using pql = priority_queue<T, vector<T>>;
template <class T>
using pq = priority_queue<T, vector<T>, greater<T>>;
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
void ansYes(bool flag) {
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void ansYES(bool flag) {
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
struct node {
  int64_t to;
  int64_t length;
};
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}
int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int main() {
  int64_t n, m;
  cin >> n >> m;
  vector<int64_t> sc(n, -1);
  for (int64_t i = 0; i < m; i++) {
    int sx, cx;
    cin >> sx >> cx;
    sx--;
    if (sx == 0 && cx == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (sc.at(sx) != -1 && sc.at(sx) != cx) {
      cout << -1 << endl;
      return 0;
    }
    sc.at(sx) = cx;
  }
  if (sc.at(0) == -1) {
    sc.at(0) = 1;
  }
  for (int64_t i = 0; i < n; i++) {
    cout << max((int64_t)0, sc.at(i));
  }
  cout << endl;
}
