#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 10000007;
vector<long> divisor(long &_n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n) tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}
long kadanes(vector<long> &_ls) {
  long highestmax = 0, currentmax = 0, length = _ls.size();
  for (long i = 0; i < length; i++) {
    currentmax = max(_ls[i], currentmax + _ls[i]);
    highestmax = max(highestmax, currentmax);
  }
  return highestmax;
}
struct init {
  init() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} init;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> sc(m);
  for (int i = 0; i < (m); i++) cin >> sc[i].first >> sc[i].second;
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    string s = to_string(i);
    bool tr = true;
    for (int j = 0; j < (m); j++) {
      if (s[sc[j].first - 1] != sc[j].second) {
        tr = false;
        break;
      }
    }
    if (tr) {
      cout << s << "\n";
      return 0;
    }
  }
  cout << "-1\n";
}
