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;
const int N = 100005, M = 100005, mod = 1e9 + 7;
template <class T>
inline void gmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <class T>
inline void gmax(T &x, const T &y) {
  if (x < y) x = y;
}
inline void ch(int &x, int y) { x = (x + y) % mod; }
inline void read(int &x) {
  x = 0;
  char ch = getchar(), rev = 0;
  while (ch > '9' || ch < '0') rev = (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x = rev ? -x : x;
}
inline int exp(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
vector<int> nex[N];
int n, m, maxb, t, dp[2][5005], a[N], b[N], last[N];
int Main(int argv) {
  for (int i = 0; i < n; i++) read(a[i]), b[i] = a[i];
  sort(b, b + n);
  m = unique(b, b + n) - b;
  for (int i = 0; i < n; i++) a[i] = lower_bound(b, b + m, a[i]) - b;
  for (int i = n - 1; ~i; i--) last[a[i]] = i + n;
  for (int i = n - 1; ~i; i--) {
    nex[i].resize(m);
    for (int j = 0; j < m; j++) nex[i][j] = last[j];
    last[a[i]] = i;
  }
  for (int i = n - 1; ~i; i--) dp[0][a[i]] = i;
  int ans = 1;
  for (int j = 2, k = 0; j <= m; j++) {
    int mn = 0x3f3f3f3f;
    k ^= 1;
    for (int i = j - 2; i < m; i++) {
      dp[k][i] = 0x3f3f3f3f;
      if (mn < 0x3f3f3f3f) gmin(dp[k][i], mn / n * n + nex[mn % n][i]);
      gmin(mn, dp[k ^ 1][i]);
      if (dp[k][i] < (long long)n * t) ans = j;
    }
  }
  printf("%d\n", ans);
  return 0;
}
void clear() {}
int main() {
  int T;
  scanf("%d", &T);
  scanf("%d%d%d", &n, &maxb, &t);
  for (int i = 1; i <= T; i++) clear(), Main(i);
  return 0;
}
