Language: C++

#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int N, Q;

    while (cin >> N >> Q, N || Q) {
        vector<pair<int, string> > memo;

        for (int i = 0; i < N; i++) {
            string s;
            int ey, wy;

            cin >> s >> ey >> wy;
            memo.push_back(make_pair(wy - ey, s));
        }
        sort(memo.begin(), memo.end());


        for (int i = 0; i < Q; i++) {
            int q;

            cin >> q;
            bool flag = false;
            for (int j = 0; j < N - 1; j++) {
                if (memo[j].first <= q && memo[j + 1].first > q) {
                    flag = true;
                    cout << memo[j].second << " " << q - memo[j].first << endl;
                    break;
                }
            }

            if (!flag)
                cout << "Unknown" << endl;
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'cin' was not declared in this scope
   11 |     while (cin >> N >> Q, N || Q) {
      |            ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <algorithm>
  +++ |+#include <iostream>
    4 | 
a.cc:12:26: error: 'string' was not declared in this scope
   12 |         vector<pair<int, string> > memo;
      |                          ^~~~~~
a.cc:4:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    3 | #include <algorithm>
  +++ |+#include <string>
    4 | 
a.cc:12:32: error: template argument 2 is invalid
   12 |         vector<pair<int, string> > memo;
      |                                ^
a.cc:12:34: error: template argument 1 is invalid
   12 |         vector<pair<int, string> > memo;
      |                                  ^
a.cc:12:34: error: template argument 2 is invalid
a.cc:15:19: error: expected ';' before 's'
   15 |             string s;
      |                   ^~
      |                   ;
a.cc:18:20: error: 's' was not declared in this scope
   18 |             cin >> s >> ey >> wy;
      |                    ^
a.cc:19:18: error: request for member 'push_back' in 'memo', which is of non-class type 'int'
   19 |             memo.push_back(make_pair(wy - ey, s));
      |                  ^~~~~~~~~
a.cc:21:19: error: request for member 'begin' in 'memo', which is of non-class type 'int'
   21 |         sort(memo.begin(), memo.end());
      |                   ^~~~~
a.cc:21:33: error: request for member 'end' in 'memo', which is of non-class type 'int'
   21 |         sort(memo.begin(), memo.end());
      |                                 ^~~
a.cc:30:25: error: invalid types 'int[int]' for array subscript
   30 |                 if (memo[j].first <= q && memo[j + 1].first > q) {
      |                         ^
a.cc:30:47: error: invalid types 'int[int]' for array subscript
   30 |                 if (memo[j].first <= q && memo[j + 1].first > q) {
      |                                               ^
a.cc:32:21: error: 'cout' was not declared in this scope
   32 |                     cout << memo[j].second << " " << q - memo[j].first << endl;
      |                     ^~~~
a.cc:32:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:33: error: invalid types 'int[int]' for array subscript
   32 |                     cout << memo[j].second << " " << q - memo[j].first << endl;
      |                                 ^
a.cc:32:62: error: invalid types 'int[int]' for array subscript
   32 |                     cout << memo[j].second << " " << q - memo[j].first << endl;
      |                                                              ^
a.cc:32:75: error: 'endl' was not declared in this scope
   32 |                     cout << memo[j].second << " " << q - memo[j].first << endl;
      |                                                                           ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include <algorithm>
  +++ |+#include <ostream>
    4 | 
a.cc:38:17: error: 'cout' was not declared in this scope
   38 |                 cout << "Unknown" << endl;
      |                 ^~~~
a.cc:38:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:38:38: error: 'endl' was not declared in this scope
   38 |                 cout << "Unknown" << endl;
      |                                      ^~~~
a.cc:38:38: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'