#include <bits/stdc++.h>
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
int dig(int n) {
  if (n == 0) return 1;
  int res = 0;
  while (n > 0) {
    res++;
    n /= 10;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<P> data(m, P(m, 0));
  for (int i = 0; i < (m); ++i) {
    cin >> data.at(i).first >> data.at(i).second;
  }
  sort(data.begin(), data.end());
  for (int i = 0; i < (m - 1); ++i) {
    if (data.at(i).first == data.at(i + 1).first) data.at(i).first = 0;
  }
  int res = 0;
  for (int i = 0; i < (m); ++i) {
    int x;
    if (data.at(i).first > 0) {
      x = pow(10, n - data.at(i).first);
    } else {
      x = 0;
    }
    res += data.at(i).second * x;
  }
  int _dig = dig(res);
  if (_dig == n) {
    if (res >= 0) {
      cout << res << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
