#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>order_set;
typedef pair<int, int>pr;
#define all(i) i.begin() , i.end()
#define ft first
#define sn second
#define pb push_back
#define totalone(mask) __builtin_popcount(mask)
#define chkbit(mask,bit) (mask&(1LL << bit))
#define setbit(mask,bit) (mask|(1LL << bit))
#define cngbit(mask,bit) (mask^(1LL << bit))
#define en "\n"
#define dbg(x) cerr<<#x<<" is : "<<x<<en;
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define report cout<<-1<<en
#define sum(n) ((1LL*(n)*(n+1))/ 2LL)
#define sqr(n) (1LL*(n)*(n))
#define vag(a,b) ((a + b - 1)/b)
#define coutv(v) for(auto i: v) cout<<i<<" ";cout<<en;
#define cinv(v) for(auto &i: v) cin >> i;
#define MAXN 100010
#define inf 1e6+5
const int mod = 1e9 + 7;
int n;
int a[MAXN];
struct segment_tree
{
struct node {
int suru , ses, value;
void init(int l, int r) {
suru = l, ses = r;
if (l == r) value = 0;
}
} g[4 * MAXN];
void fill_cn(node &cn, node &ln, node &rn) // fill_current_node
{
cn.value = (1LL * (ln.value + rn.value)) % mod;
}
void build(int cn, int l, int r)
{
g[cn].init(l, r);
if (l == r ) return;
int md = l + (r - l) / 2;
build(cn * 2, l, md);
build(cn * 2 + 1, md + 1, r);
fill_cn (g[cn], g[cn * 2] , g[cn * 2 + 1]);
}
void update(int cn, int pos, int val)
{
int x = g[cn].suru;
int y = g[cn].ses;
if (y < pos || x > pos) return;
if (pos <= x && pos >= y ) {
g[cn].value = val;
return;
}
update(cn * 2, pos, val);
update(cn * 2 + 1, pos, val);
fill_cn(g[cn], g[cn * 2], g[cn * 2 + 1]);
}
int query(int cn, int l, int r)
{
int x = g[cn].suru;
int y = g[cn].ses;
if (y < l || x > r) return 0;
if (l <= x && r >= y ) return g[cn].value;
ll A = query(cn * 2, l, r);
ll B = query(cn * 2 + 1, l, r);
int ans = (1LL * (A + B)) % mod;
return ans;
}
} stre;
bool cmp(pr a, pr b)
{
if (a.ft == b.ft) return a.sn > b.sn;
return a.ft < b.ft;
}
void solve()
{
cin >> n;
vector<pr>v;
for (int i = 1; i <= n; i++) {
cin >> a[i];
v.pb({a[i], i});
}
sort(all(v), cmp);
stre.build(1, 1, n);
for (int i = 0; i < n; i++)
{
int cn = stre.query(1, 1, v[i].sn);
stre.update(1, v[i].sn, cn + 1);
}
int an = stre.query(1, 1, n);
cout << an << en;
}
int main()
{
IOS;
ll t;
t = 1;
cin >> t;
int c = 0;
while ( t-- )
{
cout << "Case " << ++c << ": ";
solve();
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGludCBsbDsKI2RlZmluZSBJT1MgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsgIGNpbi50aWUoMCk7IGNvdXQudGllKDApOwoKI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4KdXNpbmcgbmFtZXNwYWNlIF9fZ251X3BiZHM7Cgp0eXBlZGVmIHRyZWU8aW50LCBudWxsX3R5cGUsIGxlc3M8aW50PiwgcmJfdHJlZV90YWcsIHRyZWVfb3JkZXJfc3RhdGlzdGljc19ub2RlX3VwZGF0ZT5vcmRlcl9zZXQ7CnR5cGVkZWYgcGFpcjxpbnQsIGludD5wcjsKI2RlZmluZSBhbGwoaSkgICAgIGkuYmVnaW4oKSAsIGkuZW5kKCkKI2RlZmluZSBmdCAgICAgZmlyc3QKI2RlZmluZSBzbiAgICAgc2Vjb25kCiNkZWZpbmUgcGIgcHVza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2NuKG5vZGUgJmNuLCBub2RlICZsbiwgbm9kZSAmcm4pIC8vIGZpbGxfY3VycmVudF9ub2RlCiAgICB7CiAgICAgICAgY24udmFsdWUgPSAoMUxMICogKGxuLnZhbHVlICsgcm4udmFsdWUpKSAlIG1vZDsKICAgIH0KCiAgICB2b2lkIGJ1aWxkKGludCBjbiwgaW50IGwsIGludCByKQogICAgewogICAgICAgIGdbY25dLmluaXQobCwgcik7CgogICAgICAgIGlmIChsID09IHIgKSByZXR1cm47CiAgICAgICAgaW50IG1kID0gbCArIChyIC0gbCkgLyAyOwoKICAgICAgICBidWlsZChjbiAqIDIsIGwsIG1kKTsKICAgICAgICBidWlsZChjbiAqIDIgKyAxLCBtZCArIDEsIHIpOwoKICAgICAgICBmaWxsX2NuIChnW2NuXSwgZ1tjbiAqIDJdICwgZ1tjbiAqIDIgKyAxXSk7CiAgICB9CgogICAgdm9pZCB1cGRhdGUoaW50IGNuLCBpbnQgcG9zLCBpbnQgdmFsKQogICAgewogICAgICAgIGludCB4ID0gZ1tjbl0uc3VydTsKICAgICAgICBpbnQgeSA9IGdbY25dLnNlczsKCiAgICAgICAgaWYgKHkgPCBwb3MgfHwgeCA+IHBvcykgcmV0dXJuOwogICAgICAgIGlmIChwb3MgPD0geCAmJiBwb3MgPj0geSApIHsKICAgICAgICAgICAgZ1tjbl0udmFsdWUgPSB2YWw7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CgogICAgICAgIHVwZGF0ZShjbiAqIDIsIHBvcywgdmFsKTsKICAgICAgICB1cGRhdGUoY24gKiAyICsgMSwgcG9zLCB2YWwpOwoKICAgICAgICBmaWxsX2NuKGdbY25dLCBnW2NuICogMl0sIGdbY24gKiAyICsgMV0pOwogICAgfQoKICAgIGludCBxdWVyeShpbnQgY24sIGludCBsLCBpbnQgcikKICAgIHsKICAgICAgICBpbnQgeCA9IGdbY25dLnN1cnU7CiAgICAgICAgaW50IHkgPSBnW2NuXS5zZXM7CiAgICAgICAgaWYgKHkgPCBsIHx8IHggPiByKSByZXR1cm4gMDsKCiAgICAgICAgaWYgKGwgPD0geCAmJiByID49IHkgKSByZXR1cm4gZ1tjbl0udmFsdWU7CgogICAgICAgIGxsIEEgPSBxdWVyeShjbiAqIDIsIGwsIHIpOwogICAgICAgIGxsIEIgPSAgcXVlcnkoY24gKiAyICsgMSwgbCwgcik7CiAgICAgICAgaW50IGFucyA9ICgxTEwgKiAoQSArIEIpKSAlIG1vZDsKICAgICAgICByZXR1cm4gYW5zOwogICAgfQoKfSBzdHJlOwoKYm9vbCBjbXAocHIgYSwgcHIgYikKewogICAgaWYgKGEuZnQgPT0gYi5mdCkgcmV0dXJuIGEuc24gPiBiLnNuOwogICAgcmV0dXJuIGEuZnQgPCBiLmZ0Owp9CnZvaWQgc29sdmUoKQp7CgogICAgY2luID4+IG47CiAgICB2ZWN0b3I8cHI+djsKCiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICBjaW4gPj4gYVtpXTsKICAgICAgICB2LnBiKHthW2ldLCBpfSk7CiAgICB9CgogICAgc29ydChhbGwodiksIGNtcCk7CiAgICBzdHJlLmJ1aWxkKDEsIDEsIG4pOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgewogICAgICAgIGludCBjbiA9IHN0cmUucXVlcnkoMSwgMSwgdltpXS5zbik7CiAgICAgICAgc3RyZS51cGRhdGUoMSwgdltpXS5zbiwgY24gKyAxKTsKICAgIH0KCiAgICBpbnQgYW4gPSBzdHJlLnF1ZXJ5KDEsIDEsIG4pOwogICAgY291dCA8PCBhbiA8PCBlbjsKfQppbnQgbWFpbigpCnsKICAgIElPUzsKICAgIGxsIHQ7CiAgICB0ID0gMTsKICAgIGNpbiA+PiB0OwoKICAgIGludCBjID0gMDsKICAgIHdoaWxlICggdC0tICkKICAgIHsKICAgICAgICBjb3V0IDw8ICJDYXNlICIgPDwgKytjIDw8ICI6ICI7CiAgICAgICAgc29sdmUoKTsKICAgIH0KICAgIHJldHVybiAwOwp9