#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
bool tag[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string res;
  res.resize(n);
  bool ok = 1;
  for (int i = 1; i <= m; i++) {
    int s, c;
    cin >> s >> c;
    if (tag[s - 1] && c + '0' != res[s - 1]) ok = 0;
    res[s - 1] = '0' + c;
    tag[s - 1] = 1;
  }
  if (!tag[0]) res[0] = '1';
  if (res[0] == '0' && n != 1) ok = 0;
  for (int i = 1; i < n; i++)
    if (!tag[i]) res[i] = '0';
  if (ok)
    cout << res;
  else
    cout << -1;
  return 0;
}
