#include <bits/stdc++.h>
using namespace std;
std::mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
const long long mod = 1e7;
long long ksm(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int _, n, m;
void run() {}
int main() {
  cin >> n >> m;
  vector<int> ve(n + 1);
  string s;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    ve[x] = y;
  }
  if (m < n)
    cout << -1 << endl;
  else {
    for (int i = 1; i <= n; i++) cout << ve[i];
    cout << endl;
  }
  return 0;
}
