The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree.

The New Year tree is an undirected tree with n vertices and root in the vertex 1.

You should process the queries of the two types:

  1. Change the colours of all vertices in the subtree of the vertex v to the colour c. 
  2. Find the number of different colours in the subtree of the vertex v. 

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 4·105) — the number of vertices in the tree and the number of the queries.

The second line contains n integers ci (1 ≤ ci ≤ 60) — the colour of the i-th vertex.

Each of the next n - 1 lines contains two integers xj, yj (1 ≤ xj, yj ≤ n) — the vertices of the j-th edge. It is guaranteed that you are given correct undirected tree.

The last m lines contains the description of the queries. Each description starts with the integer tk (1 ≤ tk ≤ 2) — the type of the k-th query. For the queries of the first type then follows two integers vk, ck (1 ≤ vk ≤ n, 1 ≤ ck ≤ 60) — the number of the vertex whose subtree will be recoloured with the colour ck. For the queries of the second type then follows integer vk (1 ≤ vk ≤ n) — the number of the vertex for which subtree you should find the number of different colours.

Output

For each query of the second type print the integer a — the number of different colours in the subtree of the vertex given in the query.

Each of the numbers should be printed on a separate line in order of query appearing in the input.

Examples

Input

7 10
1 1 1 1 1 1 1
1 2
1 3
1 4
3 5
3 6
3 7
1 3 2
2 1
1 4 3
2 1
1 2 5
2 1
1 6 4
2 1
2 2
2 3


Output

2
3
4
5
1
2


Input

23 30
1 2 2 6 5 3 2 1 1 1 2 4 5 3 4 4 3 3 3 3 3 4 6
1 2
1 3
1 4
2 5
2 6
3 7
3 8
4 9
4 10
4 11
6 12
6 13
7 14
7 15
7 16
8 17
8 18
10 19
10 20
10 21
11 22
11 23
2 1
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 4
1 12 1
1 13 1
1 14 1
1 15 1
1 16 1
1 17 1
1 18 1
1 19 1
1 20 1
1 21 1
1 22 1
1 23 1
2 1
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 4


Output

6
1
3
3
2
1
2
3
5
5
1
2
2
1
1
1
2
3
#include <bits/stdc++.h>
using std::pair;
using std::tuple;
using std::vector;
class Querry;
using Node = size_t;
using Color = size_t;
using Coloring = vector<Color>;
using QuerryPtr = std::unique_ptr<Querry>;
using Querries = vector<QuerryPtr>;
using AjacencyList = vector<vector<Node>>;
using Input = tuple<AjacencyList, Coloring, Querries>;
Input ReadInput(std::istream& in_stream = std::cin);
void WriteAnswer(const vector<size_t>&, std::ostream& out_stream = std::cout);
vector<size_t> ProceedQuerries(const AjacencyList& ajacency_list,
                               const Coloring& coloring,
                               const Querries& querries);
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  AjacencyList ajacency_list;
  Coloring coloring;
  Querries querries;
  std::tie(ajacency_list, coloring, querries) = ReadInput();
  auto result = ProceedQuerries(ajacency_list, coloring, querries);
  WriteAnswer(result);
  return 0;
}
enum QuerryType { PAINT, ASK };
class Querry {
 public:
  virtual QuerryType Type() const = 0;
  virtual Node PaintNode() const { throw 1; }
  virtual Color PaintColor() const { throw 1; }
  virtual Node AskNode() const { throw 1; }
};
class QuerryPaint : public Querry {
 private:
  Color color;
  Node node;

 public:
  QuerryPaint(Node node, Color color) : node(node), color(color) {}
  virtual QuerryType Type() const override { return QuerryType::PAINT; }
  virtual Node PaintNode() const override { return node; }
  virtual Color PaintColor() const override { return color; }
};
class QuerryAsk : public Querry {
 private:
  Node node;

 public:
  QuerryAsk(Node node) : node(node) {}
  virtual QuerryType Type() const override { return QuerryType::ASK; }
  virtual Node AskNode() const override { return node; }
};
using Number = size_t;
using Numbering = vector<Number>;
using Colors = std::bitset<60>;
class CountColorTree {
 private:
  struct Range {
    Number begin, end;
    Range(){};
    Range(Number left, Number right) : begin(left), end(right){};
    inline Number Size() const { return end - begin; }
    inline bool Empty() const { return begin >= end; }
    inline Number Mid() const { return (begin + end) / 2; }
    inline pair<Range, Range> Divide() const {
      return {Range(begin, Mid()), Range(Mid(), end)};
    }
    inline bool operator==(const Range& rhs) const {
      return begin == rhs.begin && end == rhs.end;
    }
    inline bool operator!=(const Range& rhs) const {
      return begin != rhs.begin || end != rhs.end;
    }
  };
  static Range Intersection(const Range& lhs, const Range& rhs);
  static Range Merge(const Range& lhs, const Range& rhs);
  struct TreeNode {
    Colors colors;
    Range range;
    TreeNode(Range range) : range(range) {}
    std::unique_ptr<TreeNode> left_son = nullptr, right_son = nullptr;
  };
  void Update(TreeNode* node);
  void MakeSons(TreeNode* node);
  bool Leaf(const TreeNode* node) const { return node->left_son == nullptr; }
  void PaintRange(Range range, Color color, TreeNode* node);
  Colors ColorsInRange(Range range, const TreeNode* node) const;
  const vector<Range> ranges;
  TreeNode root;
  inline static Colors Merge(Colors&& lhs, Colors&& rhs);
  static vector<Range> Ranges(const AjacencyList& ajacency_list);
  static void SetRangeDfs(Node node, Node parent, Number& number,
                          const AjacencyList& ajacency_list,
                          vector<Range>* result);

 public:
  CountColorTree(const AjacencyList& ajacency_list, const Coloring& coloring);
  void PaintSubTree(Node node, Color color) {
    PaintRange(ranges[node], color, &root);
  }
  size_t ColorsSubTree(Node node) {
    return ColorsInRange(ranges[node], &root).count();
  }
};
vector<size_t> ProceedQuerries(const AjacencyList& ajacency_list,
                               const Coloring& coloring,
                               const Querries& querries) {
  CountColorTree solve(ajacency_list, coloring);
  vector<size_t> answers;
  answers.reserve(querries.size());
  for (auto& querry_ptr : querries) {
    switch (querry_ptr->Type()) {
      case QuerryType::ASK: {
        Node node = querry_ptr->AskNode();
        size_t colors = solve.ColorsSubTree(node);
        answers.push_back(colors);
        break;
      }
      case QuerryType::PAINT: {
        Node node = querry_ptr->PaintNode();
        Color color = querry_ptr->PaintColor();
        solve.PaintSubTree(node, color);
        break;
      }
    }
  }
  return answers;
}
void CountColorTree::Update(TreeNode* node) {
  if (!Leaf(node)) {
    node->colors = node->left_son->colors;
    node->colors |= node->right_son->colors;
  }
}
void CountColorTree::MakeSons(TreeNode* node) {
  if (Leaf(node)) {
    auto division = node->range.Divide();
    node->left_son.reset(new TreeNode(division.first));
    node->right_son.reset(new TreeNode(division.second));
    node->left_son->colors = node->colors;
    node->right_son->colors = node->colors;
  }
}
CountColorTree::Range CountColorTree::Merge(const Range& lhs,
                                            const Range& rhs) {
  return Range(std::min(lhs.begin, rhs.begin), std::max(lhs.end, rhs.end));
}
void CountColorTree::SetRangeDfs(Node node, Node parent, Number& number,
                                 const AjacencyList& ajacency_list,
                                 vector<Range>* result) {
  Range& range = result->at(node);
  range.begin = number++;
  for (auto neighbour : ajacency_list[node]) {
    if (neighbour != parent) {
      SetRangeDfs(neighbour, node, number, ajacency_list, result);
    }
  }
  range.end = number;
}
vector<CountColorTree::Range> CountColorTree::Ranges(
    const AjacencyList& ajacency_list) {
  vector<Range> ranges(ajacency_list.size());
  Number last_number = 0;
  SetRangeDfs(0, 0, last_number, ajacency_list, &ranges);
  return ranges;
}
CountColorTree::Range CountColorTree::Intersection(const Range& lhs,
                                                   const Range& rhs) {
  return Range(std::max(lhs.begin, rhs.begin), std::min(lhs.end, rhs.end));
}
Colors CountColorTree::Merge(Colors&& lhs, Colors&& rhs) {
  lhs |= rhs;
  return std::move(lhs);
}
Colors CountColorTree::ColorsInRange(Range range, const TreeNode* node) const {
  range = Intersection(range, node->range);
  if (range.Empty()) {
    return {};
  }
  if (range == node->range) {
    return node->colors;
  }
  if (Leaf(node)) {
    return node->colors;
  }
  return Merge(ColorsInRange(range, node->left_son.get()),
               ColorsInRange(range, node->right_son.get()));
}
void CountColorTree::PaintRange(Range range, Color color, TreeNode* node) {
  range = Intersection(range, node->range);
  if (range == node->range) {
    node->colors = Colors();
    node->colors[color] = true;
    node->left_son.reset();
    node->right_son.reset();
    return;
  }
  if (range.Empty()) {
    return;
  }
  MakeSons(node);
  PaintRange(range, color, node->left_son.get());
  PaintRange(range, color, node->right_son.get());
  Update(node);
}
CountColorTree::CountColorTree(const AjacencyList& ajacency_list,
                               const Coloring& coloring)
    : ranges(Ranges(ajacency_list)), root(Range(0, ajacency_list.size())) {
  for (Node node = 0; node < coloring.size(); ++node) {
    Number order = ranges[node].begin;
    PaintRange(Range(order, order + 1), coloring[node], &root);
  }
}
void WriteAnswer(const vector<size_t>& answers, std::ostream& out_stream) {
  for (auto answer : answers) {
    out_stream << answer << '\n';
  }
}
Input ReadInput(std::istream& in_stream) {
  size_t nodes, querries_size;
  in_stream >> nodes >> querries_size;
  Coloring coloring(nodes);
  for (auto& color : coloring) {
    in_stream >> color;
    --color;
  }
  AjacencyList ajacency_list(nodes);
  for (size_t edge = 0; edge + 1 < nodes; ++edge) {
    Node a, b;
    in_stream >> a >> b;
    --a, --b;
    ajacency_list[a].push_back(b);
    ajacency_list[b].push_back(a);
  }
  Querries querries(querries_size);
  for (auto& querry : querries) {
    int type;
    in_stream >> type;
    if (type == 1) {
      Node node;
      Color color;
      in_stream >> node >> color;
      --node, --color;
      querry.reset(new QuerryPaint(node, color));
    } else {
      Node node;
      in_stream >> node;
      --node;
      querry.reset(new QuerryAsk(node));
    }
  }
  return {ajacency_list, coloring, std::move(querries)};
}
