#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1 << 30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++)
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, 0);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    ans[s] = c;
  }
  string tmp = "";
  for (int i = 0; i < ans.size(); i++) tmp += ans[i] + '0';
  if (tmp.front() == '0') {
    cout << -1 << endl;
  } else {
    cout << tmp << endl;
  }
}
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
