#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (int i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main() {
  cin.tie(0);
  cout.sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  bool res = true;
  for (long long(i) = 0, i_bound = (long long)(M); (i) < i_bound; ++i) {
    int s, c;
    cin >> s >> c;
    if (m.count(s)) {
      if (m[s] != c) {
        res = false;
      }
    } else {
      m[s] = c;
    }
  }
  if (m.count(1) and m[1] == 0) res = false;
  string ans = "";
  if (res) {
    for (int i = 1; i <= N; i++) {
      if (m.count(i)) {
        ans = ans + to_string(m[i]);
      } else {
        if (i == 1)
          ans = ans + to_string(1);
        else
          ans = ans + to_string(0);
      }
    }
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
