Under construction

Still being built. Things may change

Maximum Profit

Interview

Time limit1sMemory limit1024 MB

Summary
Given processor and monitor prices, pair them into the most systems possible and find the maximum total of the price products.
Level

Easy3 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Problem

You know that a computer system consists of one processor unit and one monitor. The warehouse of the firm "ShumenSoft" holds nn processor units and mm monitors. The ii-th processor unit costs aia_i leva, and the jj-th monitor costs bjb_j leva. The price of a computer system made from the ii-th processor unit and the jj-th monitor is ai⋅bja_i \cdot b_j. You must assemble as many computer systems as possible, so that their total value is as large as possible. Write a program profit that solves this problem.

Input

The first line contains two integers nn and mm, separated by one space. The second line contains nn integers a0,a1,…,an−1a_0, a_1, \ldots, a_{n-1}, separated by single spaces. The third line contains mm integers b0,b1,…,bm−1b_0, b_1, \ldots, b_{m-1}, separated by single spaces.

Output

On one line of standard output, print two integers separated by one space: the maximum number of computer systems that can be assembled, and their maximum total value.

Constraints

  • 1≤n,m≤10001 \le n, m \le 1000
  • 1≤ai,bj≤10001 \le a_i, b_j \le 1000

Examples1

  1. Example 1

    Input
    4 2
    1 2 3 4
    5 6
    
    Expected output
    2 39