#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
const long long MAXN = 1E6;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, si, ci;
  cin >> n >> m;
  string ans(n, '*');
  while (m--) {
    cin >> si >> ci, --si;
    if (ans[si] == '*' or ans[si] == (ci + '0'))
      ans[si] = (ci + '0');
    else
      return cout << -1 << "\n", 1;
  }
  ans[0] = (ans[0] == '*' ? '1' : ans[0]);
  for (auto &c : ans) c = (c == '*' ? '0' : c);
  return cout << (n > 1 and ans[0] == '0' ? "-1" : ans) << "\n", 0;
}
