#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LLINF = 1e18;
const long long MOD = 1e9 + 7;
const double EPS = 1e-10;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, -1);
  bool ok = true;
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0 && n > 1) ok = false;
    if (v[s] != -1 && v[s] != c) ok = false;
    v[s] = c;
  }
  if (!ok) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (v[0] == -1)
        cout << 1;
      else
        cout << v[0];
    } else {
      if (v[i] == -1)
        cout << 0;
      else
        cout << v[i];
    }
  }
  cout << endl;
}
