#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long MOD = 1e9 + 7;
using namespace std;
long long n_bits(long long n) {
  long long x = __builtin_popcount(n);
  return x;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(0);
  cout << fixed;
  long long n, m, k, pt(0), ct(0), x, y;
  long long t = 1;
  cin >> n >> m;
  string s;
  for (long long i = 0; i < n; i++) s.push_back('0');
  vector<pair<long long, long long>> q;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    s[x] = char(y + '0');
    q.push_back({x, y});
  }
  bool ok = true;
  if (s[0] - '0' == 0 && n != 1) ok = false;
  if (ok)
    for (long long i = 0; i < n; i++) cout << s[i] - '0';
  else
    cout << -1;
}
