You are given an integer array nums having length n and a 2D integer array queries where queries[i] = [idx, val].

For each query:

  1. Update nums[idx] = val.
  2. Choose an integer k with 1 <= k < n to split the array into the non-empty prefix nums[0..k-1] and suffix nums[k..n-1] such that the sum of the counts of distinct prime values in each part is maximum.

Note: The changes made to the array in one query persist into the next query.

Return an array containing the result for each query, in the order they are given.

 

Example 1:

Input: nums = [2,1,3,1,2], queries = [[1,2],[3,3]]

Output: [3,4]

Explanation:

Example 2:

Input: nums = [2,1,4], queries = [[0,1]]

Output: [0]

Explanation:

 

Constraints: