Pages

Wednesday, 20 June 2012

Let’s talk CLOUD COMPUTING

Cloud Computing, what’s the big deal? I heard someone saying that data is actually stored on cloud and could get wet due to rain water… lol Well yes could be… :P
Storing you data in a location outside your organization, where servers are actually present somewhere you don’t really know is cloud. Someone could make the definition even better for me. To actually understand the concept of what is new in cloud, one needs to understand, how things were before cloud came into existence (cloud was always their in existence, its just that the term was coined later).
Traditionally, companies had their own data servers or data centers to maintain or keep their data safe. Incase they had multiple centers they had distributed systems to maintain and use data, but the concept remains the same that each company took care of its own data through its own data centers. Incase they wanted to access this data at the same location or at different location they could do it through network. Basically, they kept their own data with themselves handled it or maintained it all by themselves.

So what’s the problem with it? Well in a way no problem. But if we understand cloud computing we will get what it helps in. Sometimes you get so used to a problem, that you don’t really think if it’s a problem. Now suppose for an X company the data servers were present in such a location with an illusion of being stored in a centralized manner, so that the company and all its centers can connect and access data from it whenever and wherever they want without worrying about the existence and maintenance of data how better it would be. Well sounds much like distributed databases except for the data is distributed throughout, what’s the difference? What if your organization is not supposed to worry about all of this hassle and handled it all to some third organization for maintaining? Sounds cool, but how does it help? X company works in a domain that has nothing to do with software. E.g X is a telecom company, all they worry about is if communication is perfect between their customers. But if X also has to maintain and keep up the database of all the communications like files sent and received from one customer to another, and this happening for a millions of customers. X will have to have a separate department that handle database, employ more workers, pay administrators, buy database servers maintain them. Distribute it to various locations. Rather if the job is being handled by a third organization which works itself in database maintenance and storage and is ready to provide the data whenever and wherever in an efficient manner with a little cost which should be surely less then employing more people and buying servers for yourself, why not go for it?
So, is that all? No, but there's more to it and more keeps growing too. This was just an example of what it really could do. Lets elaborate a bit.

Cloud services as mentioned in the earlier example are essentially divided into 3 major services. While these 3 are not the only services, but these services conquer the major part of the cloud. So what are these services:

SAAS : Software as a Service
PAAS : Platform as a Service
IAAS : Infrastructure as a Service

By now with the example stated above you probably might have had a hint of what these services really are all about.

SAAS: Software as a Service is using a Software as a service from the service provider on demand when the software is actually hosted on some cloud servers out there.
But whats the benefit? I would rather install the software on my own PC and use it when i want. Why cloud.
Suppose your work in some industry and you don't necessarily need Microsoft Office all the time. You probably may need it may be once every month or so may be to just view a document and edit it a bit. If you buy MS-Office for this reason and get it installed on your system lets see what all you did for this one year.
  1. You bought MS-Office professional for Rs. 24000 as per the latest price stated on Flipkart for 2013 edition.
  2. You called someone and paid him to have it installed on you machine since you were not good at installations and stuff.
  3. On your machine the installation took around 1 GB or more of your Hard disk drive
  4. Whenever you start it it consumes around 60 MB of RAM disk.
  5. Whenever in this year you had a problem accessing Office you called up Microsoft service center too get help from customer care and waited for long queues.
  6.  Every time Microsoft comes up with an update, you download the new update and install it which consumes more of your internet.
  7. If Microsoft decides to stop docx, pptx extensions again as they did with the Old office in their new release. Gosh!!! you buy another office.
  8. If system crashes, data done!!
Instead if you were using Office 365 which is Microsoft's cloud based Software as a Service lets see how the above mentioned steps changed.
  1. You opened any browser and accessed the URL http://office.microsoft.com/en-in/business/compare-office-365-for-business-plans-FX102918419.aspx paid some amount on per month basis or per year basis as per your need which was 3 times less then what you paid for in a local installation
  2. You accessed URL : https://office.live.com/start/Word.aspx?ui=en-US
  3. You started working opened closed edited your docs saved it. Done!!!
Thats it?
No installation charges. No space consumed on local drive. No RAM consumed other than the browser RAM. No customer care calls needed as per SLA. No upgrades needed since they will handle it all by them self. If they plan to change the file extension in the next release, it get automatically reflected. Plus Advantages also include, you can access you documents online from anywhere. Your documents are protected with you username passwords. No worries of system crash.

This was just one example of a Saas based service there are surely many more such services existing that you could look for. Now that Saas is clear Paas and Iaas will be easy to understand.

PAAS: Just like in Saas you used office to create docs, In Platform as a service a service provider, provides you with a platform to build apps. Its basically used by the developers to create web applications without worrying about the infrastructure beneath for development purpose. The benefit remains almost the same however the added ones could be that it promotes collaborative development, and comes up with so many tools for development making it easy for developers.

IAAS: Many a times you might have felt the need to have a greater storage space for some reason but did not consider buying a disk for it. Also you might have felt a need to greater CPU or RAM for some performance reason but again, why buy something for a task that wont take more than an hour. Infrastructure as a service is a way to provide you with Hardware Infrastructure over the cloud. Its been heavily used by most of the companies and users. Storage, CPU and Memory are not the only things that Iaas is limited to. There's more to it for sure. Nowadays different options are provided by different service providers only to make the world a better place to live in.

Most of these services are free to use or at least free to try. Before making a mind, if or not to purchase it. We could surely try them out.
Some well known cloud services/providers

SAAS : Facebook, Gmail
PAAS : Googel App Engine, Heroku
IAAS : Amazon, Rackspace

Friday, 15 June 2012

Corruption


A king once announced in his kingdom, "Anyone who gets him  something that is really unique, which no one in this world has will be rewarded, but if its not unique, he will be hanged" A tailor came forward and gifted him an air jacket. He said that the jacket was invisible and was made up of air. The king proudly got up wore nothing but the jacket and proudly went on a ride in the kingdom. No one else, but a 12 year old kid came forward laughing out of his innocence and honesty saying "O king!! You are wearing absolutely nothing and are roaming naked giving your kingdom a full view of yourself." This is the end of the story. Don’t really know what happened with the kid, but pretty sure he dint live thereafter!!! Hope everyone got the right message….

Friday, 8 June 2012

ACM ICPC 2011 (2)

Some rights reserved by Kiewic
Onsite Competition Registration
Once you are selected for the regionals, the college is supposed to pay a registration fees of Rs. 3500/- which is for 5 people 3 contestants one reserve and a coach. This fees includes the accommodation and food for 5 days. The fees is to be sent by DD. After having a terrible experience with the Online registration I dint take a risk of being late for the Onsite one. I sent the amount as soon as possible. The money was paid by College. Registration was accepted. We were supposed to fill online registration forms for travel and accommodation. ICPC this time also took care about those students travel expenses, for those whose colleges could not sponsor it (Our college did it for us... ;)). You can even get guests to the venue subject to availability of accommodation and at their own expenses. As i mentioned earlier, we could not register a reserve due to technical problems. We registered him as a guest. So 4 of us. Me, Shreyas Damle, Rahul Dange and Gaurav Deochakke. were all set for the Onsite Contest. Our coach couldn't come for she had work in college.

Railway Reservation
Had a tough time with this one. I already knew it since i did Google a few blogs which did mention how previous year students had problems with it. Well, so did we. We booked Kanyakumari express, waiting ticket  and 2 nights and 3 day travel. We obviously didn't wanted this. We checked again for other trains from Mumbai and found Kerala Kranti Express from Panvel to Kollam 18 rs travel and seats available. Cancelled the previous tickets booked Kerala Kranti ticket for 8th December and mailed ICPC that we will be coming a day earlier cos of unavailability of proper reservations. Not to risk the return journey booked a return ticket as well. Netravati Express for 15th December Kollam to Panvel. 

Train Journey
The best journey i ever had. Thankfully all the passengers in our berth were cooperative and talkative too (or i guess we were too social... :P ) Made friends with almost all of them. One was a teacher in Kollam and one of them was sitting with his Mom was working in Punjab, and one was a student just like us. Clicked pics with all of them throughout the journey. Got down from the train at every signal at every station, bought everything at every station. Pretty sure people admired our appetites...:P
When train reached Kerela, we were not sure if were supposed to be picked up cause we were a day earlier than expected. Called up the Technical Director of ICPC (which we were not knowing earlier, else would have never dared to do so, for such a cheap reason). A very polite sounding gentleman recieved the call and ensured that a team will be recieving us on Kayankullam Junction. Kayankullam was one station before Kollam. Thereafter got numerous calls from ICPC volunteers to check as to where the train had reached. The volunteers were standing outside the station main gate in orange ICPC T-Shirts as they had already informed us over the phone. They welcomed us. Happy lot of crowd I must say. Although I feel sorry cause I forgot their names. They took us to their Hostel.


Introduction to algorithms by MIT


Lecture 1
This blog is an extract from MIT's Introduction to Algorithm course.

First part of the course ids focused on Analysis. Second part is focused on design i.e. before u design algorithms; you have to master and analyze a bunch of algorithms. Analysis is a theoretical study of a computer program performance and resource usage.
How to make fast and memory reliable programs?
What is more important than performance?
1.        correctness
2.        simplicity
3.        maintainability
4.        cost(programmer’s time)
5.        stability(robustness)
6.        features(functionality)
7.        modularity(changes implementation easy)
8.        security
9.        scalability
10.     user friendliness

Then, why study algorithm and performance?
Some times performance is correlated to user friendliness. Some times there are real time constraints. i.e. the software wont work untilit performs a function for a particular time. Performance measures the line between feasible and infeasible. In real time , if it is not fast enough, its as good as not functional. If it simply uses more memory, its not going to work for you.
Algorithms are at the cutting edge of entrepreneurship. If you are thinking of doing something that already exists, performance isn’t that necessary. But, if you are planning to do something’s that’s never done before, than its most important.
The reason why performance is at the bottom of the heap is because performance is just like money. What good is a $100 bill for you? Instead you would want to have food worth $100, that should be of some use to you. Performance is something you pay for. E.g you pay for user friendliness, you pay for security, etc.
So for this reason, a user may gor for JAVA instead of C for it may be slow, but it gives more functionality like exceptions, Object Orientations,etc.

PROBLEM: INSERTION SORT
Input: sequence <a1,a2,a3,….,an>of numbers
Output: permutations<a’1,a’2,a’3,…..,a’n>
Such that a’1 <= a’2 <= a’3 <= ….. <= a’n
Pseudo code:
Insertion_Sort(A,n) //Sorts A[1….n]

for j = 2 to n
                do key = A[j]
                                i = j-1
                while i>0 and A[i]>key
                                do A[i+1] = A[i]
                                                i=i-1
                A[i+1]=key
Figure 1

                   
                It basically takes array A[] and at any point we are running the outer loop of j from 2 to n and the inner loop that starts with i = j-1 and goes until i = 0 .  so we are looking at some element j in the algorithm, and then we pull out here a value called a key and the important thing to note is that there is an invariant that is being maintained by the loop each time through. The invariant is that the LEFT part of the array in the above figure 1 is sorted. And the goal each time through the loop is to add one to the length of the strings that are sorted. And the way we do that is we pull out the key, and we just copy the value up like the arrows shown until we find a place for the key shown and then INSERT it in that place, hence the name INSERTION SORT. Once we have arrays till j sorted we go for j+1. now let us see an example for the same.
Example
8 2 4 9 3
2 8 4 9 3
2 4 8 9 3
2 4 8 9 3
2 3 4 8 9 sorted

Analysis of this algorithm
Running time:
  1. Depends on input. (e.g if already sorted, insertion sort has very little to do, cos every time we try to sort it would be like the step number 3 above where 9 is already sorted and was at its correct position so you don’t need to move it. Worst case is if its reverse sorted then there will be a lot of work to do, lot of shuffling to do as well.
  2. Depends on the input size. (6 elements less time 10 elements more time) so large number of elements means long time for sorting. So we handle it by:
-          parameterize things in the input size.
3. generally we want upper bound on running time i.e we want to know that the time is no more than  a certain amount reason being that represents a guarantee to the user. E.g if I tell you that there’s  aprogram that wont run more than 3 seconds, that gives you real information about how you could use it for example in a real time setting. And if I say there’s a program that goes for at least 3 seconds, it could go for years. That doesn’t give you a guarantee if you are a user.
- guarantee to the user.

Different kinds of analysis :
Worst case analysis: this is done usually
Where T(n) = maximum time on any input of size n
So as we saw running time depends on input that some times the inputs are better like in sort if already sorted less time and if reverse sorted maximum time. So we are looking at the worst case. If T(n) is not for maximum time then T(n) is a relation and not a function, because the time on input size n will depend on which input of size n, I can have many different times. But by putting a maximum at it, turns that relation into a function, cos there’s only one maximum time.
Average case analysis: this is done sometimes.
Where T(n) = expected time over all inputs of size n
What is expected time? Time of every input and average them? Time of every input times of probability that it will be there that it would occur. How do we know the probability time of every input occurs is?
Well we don’t know it.
So we need an assumption of statistical distribution of inputs. Common assumption is that all inputs are equally likely that’s called uniform distribution.
Best case analysis: bogus
Because its already done. You can cheat, it doesn’t tell u of the vast majority cases.

What is insertion sort’s worst case time?
Depends on computer you are running on.
-          Compare two algorithm for Relative speed (on same machine)
-          Absolute speed (if onde algorithm is betr than the other no matter what machine it runs on.
Asymptotic analysis: ignore machine dependent constants and look at growth of running time T(n) as n ->
Asymptotic notations
(Theta notation) q - notation:
Drop low order terms and ignore leading constants
e.g if there is a formula 3n^3+90n^2-5n+6046= q(n^3)
here n^3 is a bigger term than n^2 , n and all the leading terms thus it becomes q(n^3)

as n -> ∞ , q(n^2) algorithm always beats a q(n^3) algorithm.
n^2 will be faster than n^3
There will always be a point n0 where q(n^2) algorithm will be cheaper than q(n^3) algorithm
Insertion sort analysis
Worst case: input reverse sorted biggest element comes 1st and smallest comes last.
T(n)= S j=2 to n q(j) = q(n^2) (arithmetic series)
Is insertion sort fast? Moderately fast for small n but not for large n. Merge sort is faster instead.

MERGE SORT
Merge sort A[1….N}
1.        If n =1 done
2.         Recursively sort
A[1….[n/2]] and
A[[n/2]+1….n]
3.        Merge 2 sorted lists
Key subroutine here is merge and it works like this one of them is
20 13 7 2
12 11 9 1
We look at the two sorted arrays and see where is the smallest element and now we find 1 and two are smallest so we now look for the smallest of them and place the smallest in the new list so 1 is placed in new list. Now we compare the 1st element of first list and 2nd element from second list, similarly
Time = q(n) on n total elements
Recurrence for the program
q(1)
2T(n/2)
q(n)
Performance of merge sort T(n) = q(1) if n=1 (omit usually),2T(n/2)+ q(n) if n>1
Recursion tree T(n)=2T(n/2)+cn const c>0
T(n) = cn - > T(n/2) 2 times       

Tuesday, 27 December 2011

ACM ICPC 2011


Some rights reserved by Kiewic
Well, am not a blogger.... But few hings compel you to pen it all down somewhere.... ACM ICPC was surely one of them.
What is ACM ICPC?
Its an international programming contest. Association for Computing Machinery International Collegiate Programming Contest.



I represented my college Modern College Shivajinagar, Pune here
What is it all about?
Well, it all starts from here. Archis Gore(one of the project mentors on www.peepaal.org) in his Introduction wrote about this competition (check the 8th line...:P) . When I read about it, the term was itself completely new to me. So I googled it. I read, it is held every year in IIT Kanpur in the month of December.
Registration
 I had then planned that I will be going here come what may. I then checked for the eligibility and found out that last year the eligibility was students born on or after 1988 were eligible. I figured it out that next year its going to be 1989 or later, so with great regrets I closed the search (cos I wont be eligible then). But I told my friends who did fit in the criteria to apply for the same. Due to exam schedule no one could check for the same. So out of no where did it come to my mind on 9th October 2011 to check what was the last date to submit the names for the competition. I went to IIT Kanpur Website and found that again the eligibility was DOB 1988 or later. I jumped out of my bed!!! I was eligible. I called my friends and told them the same and started looking for the more details. And then came the next attack!!!! Registration for IIT Kanpur CLOSED. There was a link on the same website which took me to the international competition website. Here I came to know that the regional competition is held at many centers out of which one is Kanpur and the final is held at different locations in the world. This time its in Warsaw, Poland.
I thought for a while and made up my mind that I will go for the competition in some other center if not IIT Kanpur (I was under the impression that Kanpur was the only center for India). So I started looking for the same and found Dhaka as one of the centers…. And I said to myself… I m going there…:D but when I scrolled down I found Amritapuri as one of the centers. The name sounded Indian I googled it and I got it that it was in Kerala. Checked the last date of registration 9th October 2011 before 5 pm IST. I got a shock. Had to register today itself before 5 pm. I already knew the registration process as I read it on Kanpur website. The registration process was that only a college teacher or faculty member who has a college domain email address (abc@moderncollegepune.com) can register. The teacher will register as a coach and will add students. Three team members and one reserve can be added. The beauty of the day was that it was a Sunday. So college closed. I called up my placement coordinator(Mrs. Manisha Suryawanshi) and told her the whole story. She told me that principal was available in college today (luckily) cos teacher’s interviews were conducted that day. Went to the college, spoke to the HOD there with his help somehow completed the registration by 4.30 pm unfortunately couldn't register a reserve member because he didn’t get his password on time. Finally, registration was accepted.
Online Competition
There was an online competition on 16th October out of which they would select around 200 teams for regional. 780 teams were registered. Most of them were from IIT’s. The online exam seemed easy but wasn’t really so. There were 5 questions and there was an online compiler (they call it mooshak) where we were supposed to submit the answer. The competition was for 4 hours 9 am to 1 pm. So we started coding compiler to be used was strictly gcc and OS ubuntu Linux 8.0 (recommended) . The worst ever result we ever had we could solve only 1 out of 5 questions according to their needs. We actually solved 4 out of 5. but the other 3 were rejected on the grounds of space and time complexity. So with that 1 solved answer we got selected for the regional competition which was held on 10th December 2011.The reason we got selected in spite of solving just one question was the selection procedure. The procedure is such that those teams who do not solve even a single questions are eliminated. Out of the remaining teams those teams(who solved at least one problem) selection would be made based on per Institutions registration. E.g if from XYZ College 10 teams have registered, the team which solved maximum problems will be selected. The selection criteria clearly states that, though it sounds unfair, this rule is implemented for the contest cause ICPC's goal is to bring many universities together. Only 1 team out of 200 teams was supposed to be selected for finals at Poland. The finals would be sponsored by IBM. The best part I saw was the team who wins the competition is sure to be placed in Google, Microsoft or IBM. Last years winners are in Google now.

Problems for Online Competition

Problem A: Numerology

Numerology is a difficult branch of magic, involving converting words and names to numbers, and deriving mystical significance from them. Harry Potter, our hero, has never had a good head for maths, being more at home killing evil wizards or playing Quidditch, but his Divination teacher at Hogwarts school of witchcraft has assigned him a numerology project for the Progcon ceremony. She has given him two integers A and B, and has asked him to list all the numbers in the range [A...B] inclusive that contain no digit that occurs more than twice in it, in decimal representation. Harry could not figure out a magic spell to do this task, but you can perhaps help him with your 'compooter thingy' that Muggles* use. You just have to find the number of integers in the range [A..B] that contain no digit that occurs more than twice in it, in decimal representation.

Input (STDIN):

The first line contains the number of test cases T. Each of the next T lines contains two integers, A and B.

Output (STDOUT):

Output T lines, one for each case containing the required answer for the corresponding case.

Constraints:

1 <= T <= 10000
1 <= A <= B <= 10^18
Time limit: 4 seconds

Sample Input:

3
100 120
1000 1000
123 456

Sample Output:

20
0
331


Problem B: Count Dracula

Vampires are supposed to enjoy counting so much that in old Europe they would scatter some rice in coffins when they buried people, so that if the corpses came awake at night and became vampires, they would be kept busy until morning counting the grains of rice.

But not all vampires are evil, and the one in the picture has promised to help Harry Potter fight Voldemort, the evil Dark Lord. But instead of learning the magic spells Harry has listed for him, our Count gets distracted and starts to count the letters in the spells.

Can you help the Count count the letters in the spells quickly so that he can move on to actually learning and memorizing the spells?

Constraints

The word will have at most 1000 characters.
Time limit: 1 second

Input (STDIN):

The input contains a single word containing only lower-case letters.

Output (STDOUT):

Output each character followed by its count, separated by a single space. The characters should appear in order 'a' to 'z', and only the letters having a positive frequency should be output. There should be no extra white space at the end of each line.

Sample Input:

helloworld

Sample Output:

d 1
e 1
h 1
l 3
o 2
r 1
w 1



Problem C: The Way to the Sorcerer's Stone

Harry Potter has discovered that the Sorcerer's Stone of Immortality is hidden in a dungeon. Having beaten the three-headed dog to get to the dungeon, Harry discovers to his dismay that the stone is stored at the end of a long crooked corridor with N-1 bends. At each bend in the corridor (and at the start) is either a Hungarian Horntail dragon that our intrepid hero has to defeat, or a flask of magic potion that his teacher Snape has left for him. A dragon at junction 'i' takes away |S[i]| strength points from him, and a potion at junction 'i' increases Harry's strength by S[i]. If his strength drops to 0 or less, Harry dies, and no magical stone can revive him.

Note that Harry could be faced with a corridor having no bends (N=1) -- just one single straight section with a flask or a dragon at the start.

Harry has used magic before entering the corridor to determine which bends contain what, but lacks the basic simple mathematical skill to determine what minimum strength he needs to emerge from the corridor alive. Can you help him again with your compooter-thingy?

Input (STDIN):

The first line contains the number of test cases T. T cases follow. Each test case consists of N in the first line followed by N space separated integers on the next line. If the ith value is negative, it indicates that the ith segment has a dragon, otherwise it indicates a magic potion.

Output (STDOUT):

Output T lines, one for each case containing the required answer for the corresponding case.

Constraints:

1 <= T <= 100
1 <= N <= 100
-100 <= S[i] <= 100
Time limit: 2 seconds

Sample Input:

3
3
0 0 -1
3
-2 -3 -4
4
2 -2 3 -3

Sample Output:

2
10
1

Problem D: Sub-sequences

Having discovered that the Muggle-born* students of Hogwarts School of Witchcraft & Wizardry are all on Facebook, Headmaster Dumbledore decided to go with the flow and has hired an ICPC World Finalist to teach all the students about this 'compooter-thingy' and how to program it to do its 'automatic spells'. Harry is struggling with his latest homework assignment, which is as follows:

You are given a sequence of N numbers A[1..N]. Consider a sub-sequence** such that the bitwise AND of all the numbers of the sub-sequence is equal to the bitwise OR of all the numbers of the sub-sequence. Amongst all such sub-sequences, find the sub-sequence that has the maximum sum of the numbers, and print this maximum sum.

Can you help Harry finish his homework before he chews through all his writing quills in frustration?

*Muggle-born: Magical children born of non-magical parents.

Input (STDIN):

The first line contains the number of test cases T. T cases follow. Each test case consists of N in the first line followed by N space-separated integers on the next line denoting the values A[1..N].

Output (STDOUT):

Output T lines, one for each case containing the required answer(maximum sum as explained in the problem) for the corresponding case.

Constraints:

1 <= T <= 20
1 <= N <= 10000
0 <= A[i] <= 10000
Time limit: 3 seconds

Sample Input:

2
3
1 2 3
2
1 1

Sample Output:

3
2

Problem E: Append to Divide

Honeydukes' Sweet Shop has donated buckets of Bertie Bott's Every Flavor Beans (a kind of jelly bean) to the students of Hogwarts School of Witchcraft and Wizardry, one basket per House. But when the baskets (each labeled with the House number i) were delivered to the school, it was discovered that the number of sweets in each bucket were not exactly divisible by the number of students in that house A[i], and quarrels broke out about who got the extra sweets.
Harry Potter to the rescue! Harry suggested using magic to make sure that every bucket contained a number of sweets that were exactly divisible by the number of students in the corresponding House.
Can you tell us how many sweets were in the last bucket, given the way Harry's spell worked:

Given the number of students A[i] in each of the N houses, we define the array B[0..N] as follows. Initialize B[0] = 1 and for i = 1 to N, set B[i] to the smallest integer obtained by appending one or more digits (0-9) to B[i-1] such that B[i] is divisible by A[i]. Find the value of B[N] modulo 1000000007.

Input (STDIN):

The first line contains the number of test cases T. T cases follow. Each test case consists of N in the first line followed by N space-separated integers on the next line denoting the values A[1..N].

Output (STDOUT):

Output T lines, one for each case containing B[N] % 1000000007.

Constraints:

1 <= T <= 10
1 <= N <= 1000
1 <= A[i] <= 1,000,000
Time limit : 3 secs

Sample Input:

2
3
2 3 4
4
1234 56789 12345 6789

Sample Output:

1020
681070756

ONSITE COMPETITION IN MY NEXT POST......