#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (1 << 30) - 1;
const long long LINF = (1LL << 62) - 1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  for (int i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    --s;
    if (!s && !c || num[s] >= 0 && num[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    num[s] = c;
  }
  for (int i = 0; i < (n); i++) {
    if (num[i] >= 0)
      cout << num[i];
    else if (i)
      cout << 0;
    else
      cout << 1;
  }
  cout << endl;
  return 0;
}
