#include <bits/stdc++.h>
using namespace std;
using LL = long long;
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;
}
const int INF = 1e9;
const LL LLINF = 1e16;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> d(n, -1);
  bool f = 0;
  for (int i = (0); i < (m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (d[s] != -1 && d[s] != c)
      f = 1;
    else
      d[s] = c;
  }
  if (d[0] == 0) f = 1;
  if (f) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = (1); i < (n); i++)
    if (d[i] == -1) d[i] = 0;
  if (d[0] == -1) d[0] = 1;
  for (auto&& i : d) cout << i;
  cout << endl;
}
