P18660 [HackerEarth] Ma5termind is very fond of ice-creams. He bought himself N ice-creams of two types which are represented in the form of string of 0's and 1's such that 0 represents ice-cream of type 1 a
普及-
题目描述

Ma5termind is very fond of ice-creams. He bought himself N ice-creams of two types which are represented in the form of string of 0's and 1's such that 0 represents ice-cream of type 1 and 1 represents ice-cream of other type. Now he is in dilemma to eat which ice-cream first.So to make things simple he decided to eat all ice-cream of one type first and then the other type ice-cream. But ice-cream of both types are arranged in random order. He can perform a swap operation in which he can swap ice-cream from any position i and j.
Now ma5termind wants to seggregate ice-cream of two types in minimum possible number of swaps otherwise ice cream will melt and he will become sad.

Help him figure out the minimum number of swaps needed.
Input:
Each input file will contain a T test case.
First line will contain N the number of ice-creams and the next line will contain a string of 0's and 1's denoting the types of ice-creams.

Ouput:
For each testcase print a single integer denoting the minimum swaps.
Constraints:

1 ≤ T ≤ 5
1 ≤ N ≤ 10^5

See sample I/O for more clarification.

Scoring:

subtask 1: 1 ≤ N ≤ 1000 ( 20 pts )
subtask 2: 1 ≤ N ≤ 10^5 ( 80 pts )

SAMPLE INPUT
2
4
1001
4
1010

SAMPLE OUTPUT
1
1

Explanation

In the first sample test we can get 1100 by swaping ice-cream from position 2nd and 4th and swaps operations performed will be 1.

输入格式

见题面

输出格式

见题面

样例输入
5 963 000011010100010111100111100001111100011001111000101010001011011110000101001110111101100010110101001000101010110000000110110111001011100010001111000110011100101000011100110010001110000101001001100101011110010011101110001001001101111010001101110001100010001011110000111001100010111011101011011110001100111110100011111011110011000010101100000100100110110110011001000110001000111110000100110000110010000010011010101110101010011001111011011010100001000101100001011010111011010101101100001100110010111011000100010110111101011001111010001101001011001100001100010010100110011110001111010010000000001100000111000101111110110110011111010001001110110101110111101101110100011111110011110100110111010000100101011010010101110111001001001110110001001100000011101010010000110100000001001001100101110111110011110010100011100111000001111111001101010101111110100101101100110001010010010110010010100001000110101111110000101000010100010011011000101101100111110000101011010100000011101 833 11100101111001111010011010111111111000011100000000100110100100011011110110101111100010000010111000010111011010110111101110011001101100110101010001100010101000100010101010111000101111000011011110101000000010001110110100110000100101000111111111100101011110111010111110011111000100100011110010001001101011000000001101011110110101001101001100001111010011010111111100010011011111100000101000111011001001000111011000100001011000100110100000001010101111001100001001111000010110111101001110001110010001110001001111101100011001101100101110110101101100111100001001010100100101010101110110011110111010110111101111000010001001000111011110001001100001010111100001001000100000011010111100100001000101000010111100111010000110100000010010011110010111001100011100111011001101100110011100011100111100111110010110110000010110100110000010110100110110100 459 000111101111111100010001000001101011000010111100111101000001100000000000111000001001000100110011111001011011001101100110110001010100010011010010100000010110110000110101001011101000011100000000010100000011110101001001010111001100000011101101000011011100010100110101010111010000011100011011010110000111110001001000100001110010011110010000010010110000111101001000001011110101000000011001110001110010000001011111010000011101001011011100011101000010101101111101111 966 111111011111011100011110010100111111111111101001100010010100100011011101110100110010010111111000111100010011101110110100111101110010000111110100001001101000110011011000110100010110101010100100001001001000100111011111001011011101111010100011011000011100010011100000010100101111100011001101111111100000101101101111100001101110000010101110110101110110011011011100010110110110111011101010000110000101010111010000000110011111010111110010101110001011100000111001001010110010110110110010111110111010001110101011000000001100010100110000101010101000001011010011001010100011110110011001110010010010110000010001001110111101010110111000100111000011010000010101101101110000101001100111111001000001001001101010101000110101010001001010111100111110110011010110010000000101101100011111101011001000100100110010101110101110111011101010101000110100110110001100010011011100101110111101111100001001110001001010001010010111000011001110110011001111101111001001001110011000010001101111011111 783 111101010001100010111000111011111001011001000110110000001101000111100100111000100001011011110111100000001010100010101001010100001101011110011100110100100100011010110010110001000111010110100101101101101001111101011010011100100110010010101011001110000011010001011100111000011001011111010101010011111010101111111110010010110001010100000011001110001110000100011000110010011111111101001100000011110111011110111101010000100011001110011001011010110010001100000110111101100001010101110110110101000100001001000011001000101010100010101011110001010100001111111111110110101111000101011111100001010110111001110111011111111110100100100011110100101100111010111011000100101010001011010100110000110111001000100100001101011100011000010001000111011110110000010111001101010100110110110110001110010100011
样例输出
24044 24815 23036 24861 23598