#include <bits/stdc++.h>
using namespace std;
constexpr int inf = 0x3f3f3f3f;
constexpr long long INF = 9123456789123456789;
constexpr long long MOD = 1000000007LL;
int N, M;
void sol() {}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  cin.tie(nullptr);
  cin >> N >> M;
  string str;
  vector<bool> chk(N, false);
  for (int i = 0; i < N; i++) str += '0';
  for (int i = 0; i < M; i++) {
    int s;
    char c;
    cin >> s >> c;
    if (chk[s - 1] && str[s - 1] != c) {
      cout << "-1\n";
      return 0;
    }
    str[s - 1] = c;
    chk[s - 1] = true;
  }
  if (str[0] == '0' && chk[0]) {
    cout << "-1\n";
    return 0;
  }
  if (str[0] == '0') str[0] = '1';
  cout << str;
  return 0;
}
