description: 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
solution: #include <bits/stdc++.h>
  using namespace std;
  void main0();
  int main() {
    clock_t start, end;
    ios::sync_with_stdio(false);
    cin.tie(0);
    main0();
    return 0;
  }
  const int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1};
  const int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1};
  const int N = 1e7 + 5;
  const int M = 1e5;
  const int INF = 0x3f3f3f3f;
  const long long INFF = 0x3f3f3f3f3f3f3f3f;
  const int mod = 998244353;
  const double eps = 1e-6;
  mt19937 rnd(
      (unsigned int)chrono::steady_clock::now().time_since_epoch().count());
  template <typename T>
  bool chkmin(T &x, T y) {
    return y < x ? x = y, 1 : 0;
  }
  template <typename T>
  bool chkmax(T &x, T y) {
    return y > x ? x = y, 1 : 0;
  }
  int n;
  int a[N];
  struct status {
    int pre;
    int x, y;
    int val;
  } s[N];
  int p = 0;
  void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
    }
    s[p = 1] = {-1, -INF, -INF, -INF};
    vector<int> lst, cur;
    lst.push_back(1);
    for (int i = 1; i <= n; ++i) {
      for (int j : lst) {
        auto [pre, x, y, val] = s[j];
        for (int newx : {-a[i], a[i]})
          if (x < newx) {
            s[++p] = {j, newx, y, newx};
            cur.push_back(p);
          }
        for (int newy : {-a[i], a[i]})
          if (y < newy) {
            s[++p] = {j, x, newy, newy};
            cur.push_back(p);
          }
      }
      if (((int)(cur).size()) == 0) return (void)(cout << "NO" << endl);
      lst.clear();
      sort((cur).begin(), (cur).end(), [](int a, int b) {
        if (s[a].x != s[b].x) return s[a].x < s[b].x;
        return s[a].y < s[b].y;
      });
      for (int j : cur) {
        if ((((int)(lst).size()) == 0) || (s[j].y < s[lst.back()].y))
          lst.push_back(j);
      }
      cur.clear();
    }
    cout << "YES" << endl;
    vector<int> ans;
    int u = lst[0];
    while (s[u].pre != -1) {
      ans.push_back(s[u].val);
      u = s[u].pre;
    }
    reverse((ans).begin(), (ans).end());
    for (int i : ans) {
      cout << i << ' ';
    }
    cout << endl;
  }
  void main0() {
    int T;
    cin >> T;
    while (T--) {
      solve();
    }
  }
  