#include <bits/stdc++.h>
using namespace std;
void checkStream() {
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  size_t n{}, m{};
  cin >> n >> m;
  string ans(n, '0');
  while (m--) {
    size_t i{};
    char num{};
    cin >> i >> num;
    ans.at(i - 1) = num;
  }
  if (ans.front() == '0')
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
