You need to write N same characters on a screen and each time you can insert a character, delete the last character and copy and paste all written characters i.e. after copy operation count of total written character will become twice. Now you are given time for insertion, deletion and copying. You need to output minimum time to write N characters on the screen using these operations.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N denoting the number of same characters to write on screen. The next line contains time for insertion, deletion and copying respectively.

**Output:**

Print the minimum to write N characters on the screen.

**Constraints:**

1<=T<=100

1<=N<=100

1<=insert,remove,copy<=N

**Example:
Input:**

2

9

1 2 1

10

2 5 4

**Output:**

5

14

Ibrahim Nash | 98 |

Stark_Maverick | 77 |

Eduardo Feo | 66 |

Micky_Kt | 62 |

Rohit Sharma 16 | 61 |

Lam Ngoc Pham | 463 |

All Is Well | 399 |

Divvya Sinha | 374 |

Prateek Gole | 369 |

Ibrahim Nash | 338 |

akhayrutdinov | 3855 |

sanjay05 | 3366 |

Michael Riegger | 2030 |

Jasleen Kaur 2 | 2012 |

Quandray | 1969 |