#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, s, c;
  map<int, int> con;
  cin >> m >> n;
  int max_s = 0;
  for (int i = 0; i < (m); i++) {
    cin >> s >> c;
    max_s = max(s, max_s);
    if (con.count(s)) {
      if (con[s] != c) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      con[s] = c;
    }
  }
  if (max_s < n or con[max_s] == 0) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  for (auto p : con) {
    auto s = p.first;
    auto c = p.second;
    ans += c * pow(10, n - s);
  }
  cout << ans << endl;
  return 0;
}
