#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long int countGreater(long long int arr[], long long int n,
                           long long int k) {
  long long int l = 0;
  long long int r = n - 1;
  long long int leftGreater = n;
  while (l <= r) {
    long long int m = l + (r - l) / 2;
    if (arr[m] > k) {
      leftGreater = m;
      r = m - 1;
    } else
      l = m + 1;
  }
  return (n - leftGreater);
}
bool is_palin(string input) {
  if (input == string(input.rbegin(), input.rend())) return true;
  return false;
}
long long int precomp[5] = {1, 10, 100, 1000, 10000};
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int num[n];
  for (long long int i = 0; i < n; i++) num[i] = -1;
  for (long long int i = 0; i < m; i++) {
    long long int pos, val;
    cin >> pos >> val;
    if (num[pos - 1] != -1 && num[pos - 1] != val) {
      cout << -1;
      return;
    }
    num[pos - 1] = val;
  }
  if (num[0] == 0 && n != 0) {
    cout << -1;
    return;
  }
  if (num[0] == -1) {
    if (n == 1)
      num[0] = 0;
    else
      num[0] = 1;
  }
  for (long long int i = 0; i < n; i++)
    if (num[i] == -1) num[i] = 0;
  for (long long int i = 0; i < n; i++) cout << num[i];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
