Maxim loves sequences, especially those that strictly increase. He is wondering, what is the length of the longest increasing subsequence of the given sequence a?

Sequence a is given as follows: 

  * the length of the sequence equals n × t; 
  * <image> (1 ≤ i ≤ n × t), where operation <image> means taking the remainder after dividing number x by number y. 



Sequence s1, s2, ..., sr of length r is a subsequence of sequence a1, a2, ..., an, if there is such increasing sequence of indexes i1, i2, ..., ir (1 ≤ i1 < i2 < ... < ir ≤ n), that aij = sj. In other words, the subsequence can be obtained from the sequence by crossing out some elements.

Sequence s1, s2, ..., sr is increasing, if the following inequality holds: s1 < s2 < ... < sr.

Maxim have k variants of the sequence a. Help Maxim to determine for each sequence the length of the longest increasing subsequence.

Input

The first line contains four integers k, n, maxb and t (1 ≤ k ≤ 10; 1 ≤ n, maxb ≤ 105; 1 ≤ t ≤ 109; n × maxb ≤ 2·107). Each of the next k lines contain n integers b1, b2, ..., bn (1 ≤ bi ≤ maxb). 

Note that for each variant of the sequence a the values n, maxb and t coincide, the only arrays bs differ.

The numbers in the lines are separated by single spaces.

Output

Print k integers — the answers for the variants of the sequence a. Print the answers in the order the variants follow in the input.

Examples

Input

3 3 5 2
3 2 1
1 2 3
2 3 1


Output

2
3
3
#include <bits/stdc++.h>
using namespace std;
int b[100100], INF = 1000000000;
int main(void) {
  int Q, n, T;
  scanf("%d%d%*d%d", &Q, &n, &T);
  while (Q--) {
    vector<int> x;
    for (int i = 0; i < (n); ++i) {
      scanf("%d", &b[i]);
      x.push_back(b[i]);
    }
    sort((x).begin(), (x).end());
    x.erase(unique((x).begin(), (x).end()), x.end());
    int N = ((int)((x).size()));
    for (int i = 0; i < (n); ++i) {
      b[i] = lower_bound((x).begin(), (x).end(), b[i]) - x.begin();
    }
    vector<vector<int> > next(N);
    for (int i = 0; i < (N); ++i) {
      next[i] = vector<int>(n);
      for (int j = n - 1; j >= 0; --j) {
        if (j == n - 1) {
          next[i][j] = -1;
        } else {
          next[i][j] = next[i][j + 1];
        }
        if (b[j] == i) {
          next[i][j] = j;
        }
      }
    }
    int res = 0;
    vector<vector<pair<int, int> > > gdzie(N + 1);
    for (int i = 0; i < N; ++i) {
      gdzie[i] = vector<pair<int, int> >(N);
      int mn = INF;
      if (i == 0) {
        for (int j = 0; j < N; ++j) {
          gdzie[0][j] = make_pair(1, next[j][0]);
        }
        mn = 1;
      } else {
        pair<int, int> best = make_pair(INF, INF);
        for (int j = i; j < N; ++j) {
          best = min(best, gdzie[i - 1][j - 1]);
          if (next[j][best.second] != -1) {
            gdzie[i][j] = make_pair(best.first, next[j][best.second]);
          } else {
            gdzie[i][j] = make_pair(best.first + 1, next[j][0]);
          }
          mn = min(mn, gdzie[i][j].first);
        }
        if (mn > T) {
          break;
        }
      }
      res = i + 1;
    }
    printf("%d\n", res);
  }
  return 0;
}
