#include <bits/stdc++.h>
using namespace std;
template <class Type_a, class Type_b>
bool chmax(Type_a &a, const Type_b &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class Type_a, class Type_b>
bool chmin(Type_a &a, const Type_b &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class Type>
void line(const Type &a) {
  int cnt = 0;
  for (const auto &elem : a) {
    if (cnt++) cout << ' ';
    cout << elem;
  }
  cout << endl;
}
template <class Type>
int digit(Type x) {
  return (x == 0) ? 1 : floor(log10(x)) + 1;
}
int main() {
  int tmp;
  cin >> tmp;
  cerr << "digit(tmp)"
       << ": " << (digit(tmp)) << endl;
  int n;
  int m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  for (int i = 0; i < (1000); ++i) {
    if (digit(i) != n) continue;
    string num = to_string(i);
    bool jud = true;
    for (int j = 0; j < (m); ++j) {
      if (num[s[j] - 1] - '0' != c[j]) jud = false;
    }
    if (jud) {
      cout << num << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
