#include using namespace std; void te() { int n; scanf("%d", &n); vector t(n); for(int i = 0; i < n; ++i) scanf("%d", &t[i]); for(int i = n - 1; i >= 1; --i) if(t[i] != -1 && t[i] != 1) { int should = t[i] - 1; if(t[i-1] == -1) t[i-1] = should; else if(t[i-1] != should) { puts("0"); return; } } if(t[0] != -1 && t[0] != 1) { puts("0"); return; } int ans = 1; for(int i = 1; i < n; ++i) // without t[0] if(t[i] == -1) ans = 2 * ans % (1000 * 1000 * 1000 + 7); printf("%d\n", ans); } int main() { int T; scanf("%d", &T); while(T--) te(); }