#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);
  vector<bool> v1(n, false);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (v[s - 1] != c && v1[s - 1]) {
      cout << -1 << endl;
      return 0;
    }
    v[s - 1] = c;
    if (s - 1 == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    v1[s - 1] = true;
  }
  if (n != 1 && v[0] == 0) {
    v[0] = 1;
  }
  for (int i = 0; i < n; i++) {
    cout << v[i];
  }
  cout << endl;
}
