#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n, m;
   cin >> n;
   vector<P> p(m);
   rep(i, m) cin >> p[i].first >> p[i].second;
   rep(i, 1000) {
      int keta = 1;
      int nx = x / 10;
      vector<int> d(1, x % 10);
      while (nx) {
         keta++;
         d.push_back(nx % 10);
         nx /= 10;
      }
      if (keta != n)
         continue;
      reverse(d.begin(), d.end());
      bool isok = true;
      rep(i, m) {
         if (d[p[i].first - 1] != p[i].second)
            isok = false;
      }
      if (isok) {
         cout << x << endl;
         return 0;
      }
   }
   cout << -1 << endl;
   return 0;
}