This page is still under construction.

Parts of this page are still being built. What you see may change.

Counting Antibodies

Time limit1sMemory limit512 MB

Summary
Given the gene fragment counts for the kappa, lambda, and heavy chains, count how many distinct antibody molecules can be formed.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Immunoglobulins, also known as antibodies, are protein molecules. Antibodies play a major role in the immune reaction. They detect harmful foreign agents (bacteria or viruses) and help to eliminate them. Every foreign molecule binds with a unique type of antibody. There are plenty of potential harmful agents, so there should be a tremendous number of immunoglobulin types to neutralize all threats. The required number of immunoglobulin types is too large to encode each type in DNA. Luckily, there is a solution.

Immunoglobulins are produced by immune cells called B-lymphocytes, based on DNA information, namely genes. Immunoglobulin genes are assembled from DNA fragments, like a set of building blocks. Each fragment exists in several variants and is responsible for a variable region of the immunoglobulin molecule. This process is called somatic recombination.

An immunoglobulin molecule consists of two identical heavy chains and two identical light chains. There are two types of light chains with similar structure: κ\kappa and λ\lambda. Both light chain types have two variable regions, VV and JJ. To form a variable region, one gene fragment is selected from multiple variants. For the κ\kappa light chain, the VV and JJ regions select from the VκV_\kappa and JκJ_\kappa variants, respectively. For the λ\lambda light chain, they select from the VλV_\lambda and JλJ_\lambda variants, respectively.

There is only one heavy chain type, with three variable regions: VV, DD, and JJ. To form each of them, one gene fragment is selected from the VhV_h, DhD_h, and JhJ_h variants, respectively.

You need to count how many possible immunoglobulin molecules can be produced for given values of VκV_\kappa, JκJ_\kappa, VλV_\lambda, JλJ_\lambda, VhV_h, DhD_h, and JhJ_h.

Input

The first line contains two integers VκV_\kappa and JκJ_\kappa (1≤Vκ,Jκ≤15001 \leq V_\kappa, J_\kappa \leq 1500), the number of gene fragment variants for the VV and JJ variable regions of the κ\kappa light chain.

The second line contains two integers VλV_\lambda and JλJ_\lambda (1≤Vλ,Jλ≤15001 \leq V_\lambda, J_\lambda \leq 1500), the number of gene fragment variants for the VV and JJ variable regions of the λ\lambda light chain.

The third line contains three integers VhV_h, DhD_h, and JhJ_h (1≤Vh,Dh,Jh≤10001 \leq V_h, D_h, J_h \leq 1000), the number of gene fragment variants for the heavy chain VV, DD, and JJ variable regions.

Output

Output one integer: the number of immunoglobulin variants that can be produced.

Hint

Somatic recombination is a powerful protective mechanism against various bacteria and viruses, but it is not the only one. Other ways to prevent foreign invasion are beyond the scope of this problem.

Examples1

  1. Example 1

    Input
    40 5
    41 6
    50 30 6
    
    Expected output
    4014000