Build a simple room in ASCII-art A room can be made up of connected rectangles, for instance an L-shaped room. Such a room can be described by a list of dimensions describing the size of each rectangle. 

Assume you have two input lists. The first contains the width of rectangles stacked vertically over each other. The second contains the height of the rectangles. 

As an example, the input [4 6][3 2] will be a 4-by-3 rectangle on top of a 6-by-2 rectangle. The figure below shows this shape. Note that the walls are considered "thin", thus it's the spaces between the wall that's determined by the input.  

[4 6][3 2]
 ____
|    |
|    |
|    |_
|      |
|______|


The challenge is: Take a list of dimensions as input, and output the shape of the room as ASCII-art. The format must be as in the sample figures:


All horizontal walls are shown using underscores
All vertical walls are shown using bars
There shall be no walls where the rectangles are connected
The left wall is straight
For more details, have a look at the test cases


Assumptions you can make:


All dimensions are in the range [1 ... 20]


All horizonal dimensions are even numbers

The number of rectangles will be in the range [1 ... 10]
Only valid input is given
Optional input format (you can decide the order of the input dimensions, please specify in the answer).


Test cases:

[2][1]
 __
|__|

---

[4][2]
 ____
|    |
|____|

---

[2 6 2 4][2 2 1 3]
 __
|  |
|  |___
|      |
|   ___|
|  |_
|    |
|    |
|____|

---

[2 14 6 8 4 18 2 10 4 2][1 2 3 1 2 1 1 1 2 1]
 __
|  |___________
|              |
|       _______|
|      |
|      |
|      |_
|     ___|
|    |
|    |_____________
|   _______________|
|  |______
|     ____|
|    |
|   _|
|__|
Python 3, 230 223 222 217 bytes

def f(a):b=a[0]+[0];m=' _';print('\n'.join([' '+'_'*b[0]+' ']+['|'+' '*min(b[l],b[l+1])+m[b[l+1]&lt;1]*(b[l]&gt;b[l+1])+m[k]*(b[l]-b[l+1]-1)+'|'+m[k]*(b[l+1]-b[l]-1)for l,i in enumerate(zip(*a))for k in[0]*(i[1]-1)+[1]]))


Thanks to @StewieGriffin  @KevinLau for their help 

Results

&gt;&gt;&gt; f([[2, 14, 6, 8, 4, 18, 2, 10, 4, 2],[1, 2, 3, 1, 2, 1, 1, 1, 2, 1]])
 __ 
|  |___________
|              |
|       _______|
|      | 
|      | 
|      |_
|     ___|
|    |             
|    |_____________
|   _______________|
|  |_______
|     _____|
|    |
|   _|
|__|