#include <bits/stdc++.h>
using namespace std;
int cas;
int arr[2000005];
int dp[2000005][2][2];
int casio[2000005][2][2];
int f(int i, int flag, int sgn) {
  if (i == 0) return -10000000;
  int cur = arr[i];
  if (sgn) cur *= -1;
  int ret = 10000000;
  if (casio[i][flag][sgn] == cas) return dp[i][flag][sgn];
  casio[i][flag][sgn] = cas;
  if (flag) {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur > a) ret = min(ret, pre);
    a = f(i - 1, 1, 0);
    if (cur > pre && cur > a) ret = min(ret, a);
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur > a) ret = min(ret, pre);
    a = f(i - 1, 1, 1);
    if (cur > pre && cur > a) ret = min(ret, a);
  } else {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur < a) ret = min(ret, a);
    a = f(i - 1, 1, 0);
    if (cur < pre && cur > a) ret = min(ret, pre);
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur < a) ret = min(ret, a);
    a = f(i - 1, 1, 1);
    if (cur < pre && cur > a) ret = min(ret, pre);
  }
  return dp[i][flag][sgn] = ret;
}
void dfs(int i, int flag, int sgn) {
  if (sgn) arr[i] *= -1;
  if (i == 0) return;
  int cur = arr[i];
  int ret = f(i, flag, sgn);
  if (flag) {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur > a && ret == pre) {
      dfs(i - 1, 0, 0);
      return;
    }
    a = f(i - 1, 1, 0);
    if (cur > pre && cur > a && ret == a) {
      dfs(i - 1, 1, 0);
      return;
    }
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur > a && ret == pre) {
      dfs(i - 1, 0, 1);
      return;
    }
    a = f(i - 1, 1, 1);
    if (cur > pre && cur > a && ret == a) {
      dfs(i - 1, 1, 1);
      return;
    }
  } else {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur < a && ret == a) {
      dfs(i - 1, 0, 0);
      return;
    }
    a = f(i - 1, 1, 0);
    if (cur < pre && cur > a && ret == pre) {
      dfs(i - 1, 1, 0);
    }
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur < a && ret == a) {
      dfs(i - 1, 0, 1);
      return;
    }
    a = f(i - 1, 1, 1);
    if (cur < pre && cur > a && ret == pre) {
      dfs(i - 1, 1, 1);
      return;
    }
  }
}
void solve() {
  cas++;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (f(n - 1, 0, 0) <= n)
    dfs(n - 1, 0, 0);
  else if (f(n - 1, 0, 1) <= n)
    dfs(n - 1, 0, 1);
  else if (f(n - 1, 1, 0) <= n)
    dfs(n - 1, 1, 0);
  else if (f(n - 1, 1, 1) <= n)
    dfs(n - 1, 1, 1);
  else {
    cout << "NO" << '\n';
    return;
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; i++) cout << arr[i] << ' ';
  cout << '\n';
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}

### Prompt

In cpp, your task is to solve the following problem:

You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).

Let's call an array a bipartite if the following undirected graph is bipartite:

  * the graph consists of n vertices; 
  * two vertices i and j are connected by an edge if i < j and a_i > a_j. 



Your task is to find a bipartite array of integers a of size n, such that a_i = p_i or a_i = -p_i, or report that no such array exists. If there are multiple answers, print any of them.

Input

The first line contains a single integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases.

The first line of each test case contains a single integer n (1 ≤ n ≤ 10^6) — the size of the permutation.

The second line contains n integers p_1, p_2, ..., p_n.

The sum of n over all test cases doesn't exceed 10^6.

Output

For each test case, print the answer in the following format. If such an array a does not exist, print "NO" in a single line. Otherwise, print "YES" in the first line and n integers — array a in the second line.

Example

Input


4
3
1 2 3
6
1 3 2 6 5 4
4
4 1 3 2
8
3 2 1 6 7 8 5 4


Output


YES
1 2 3
NO
YES
-4 -1 -3 -2
YES
-3 -2 1 6 7 -8 -5 -4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int cas;
int arr[2000005];
int dp[2000005][2][2];
int casio[2000005][2][2];
int f(int i, int flag, int sgn) {
  if (i == 0) return -10000000;
  int cur = arr[i];
  if (sgn) cur *= -1;
  int ret = 10000000;
  if (casio[i][flag][sgn] == cas) return dp[i][flag][sgn];
  casio[i][flag][sgn] = cas;
  if (flag) {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur > a) ret = min(ret, pre);
    a = f(i - 1, 1, 0);
    if (cur > pre && cur > a) ret = min(ret, a);
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur > a) ret = min(ret, pre);
    a = f(i - 1, 1, 1);
    if (cur > pre && cur > a) ret = min(ret, a);
  } else {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur < a) ret = min(ret, a);
    a = f(i - 1, 1, 0);
    if (cur < pre && cur > a) ret = min(ret, pre);
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur < a) ret = min(ret, a);
    a = f(i - 1, 1, 1);
    if (cur < pre && cur > a) ret = min(ret, pre);
  }
  return dp[i][flag][sgn] = ret;
}
void dfs(int i, int flag, int sgn) {
  if (sgn) arr[i] *= -1;
  if (i == 0) return;
  int cur = arr[i];
  int ret = f(i, flag, sgn);
  if (flag) {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur > a && ret == pre) {
      dfs(i - 1, 0, 0);
      return;
    }
    a = f(i - 1, 1, 0);
    if (cur > pre && cur > a && ret == a) {
      dfs(i - 1, 1, 0);
      return;
    }
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur > a && ret == pre) {
      dfs(i - 1, 0, 1);
      return;
    }
    a = f(i - 1, 1, 1);
    if (cur > pre && cur > a && ret == a) {
      dfs(i - 1, 1, 1);
      return;
    }
  } else {
    int pre = arr[i - 1];
    int a = f(i - 1, 0, 0);
    if (cur > pre && cur < a && ret == a) {
      dfs(i - 1, 0, 0);
      return;
    }
    a = f(i - 1, 1, 0);
    if (cur < pre && cur > a && ret == pre) {
      dfs(i - 1, 1, 0);
    }
    pre *= -1;
    a = f(i - 1, 0, 1);
    if (cur > pre && cur < a && ret == a) {
      dfs(i - 1, 0, 1);
      return;
    }
    a = f(i - 1, 1, 1);
    if (cur < pre && cur > a && ret == pre) {
      dfs(i - 1, 1, 1);
      return;
    }
  }
}
void solve() {
  cas++;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (f(n - 1, 0, 0) <= n)
    dfs(n - 1, 0, 0);
  else if (f(n - 1, 0, 1) <= n)
    dfs(n - 1, 0, 1);
  else if (f(n - 1, 1, 0) <= n)
    dfs(n - 1, 1, 0);
  else if (f(n - 1, 1, 1) <= n)
    dfs(n - 1, 1, 1);
  else {
    cout << "NO" << '\n';
    return;
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; i++) cout << arr[i] << ' ';
  cout << '\n';
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}

```