#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
  int n, m;
  cin >> n >> m;

  vector<int> s(m);
  vector<char> c(m);

  for (int i = 0; i < m; i++)
    cin >> s[i] >> c[i];

  for (int i = 0; i < 1000; i++) {
    bool flag = true;
    string str = to_string(i);
    if (str.length() < n)
      continue;
    for (int j = 0; j < m; j++) {
      if (str[s[j] - 1] != c[j])
        flag = false;
    }
    if (flag) {
      cout << str << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
  int n, m;
  cin >> n >> m;

  vector<int> s(m);
  vector<char> c(m);

  for (int i = 0; i < m; i++)
    cin >> s[i] >> c[i];

  for (int i = 0; i < 1000; i++) {
    bool flag = true;
    string str = to_string(i);
    if (str.length() < n)
      continue;
    for (int j = 0; j < m; j++) {
      if (str[s[j] - 1] != c[j])
        flag = false;
    }
    if (flag) {
      cout << str << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
  int n, m;
  cin >> n >> m;

  vector<int> s(m);
  vector<char> c(m);

  for (int i = 0; i < m; i++)
    cin >> s[i] >> c[i];

  for (int i = 0; i < 1000; i++) {
    bool flag = true;
    string str = to_string(i);
    if (str.length() < n)
      continue;
    for (int j = 0; j < m; j++) {
      if (str[s[j] - 1] != c[j])
        flag = false;
    }
    if (flag) {
      cout << str << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
