#include<bits/stdc++.h> using namespace std; int n,ans,k,a,b,c; int main(){ cin>>n; while(n--){ cin>>k; if(k==1){ cin>>a>>b; ans+=(a+b)*2; } if(k==2){ cin>>a; ans+=4*a; } if(k==3){ cin>>a>>b>>c; ans+=a+b+c; } } cout<<ans; return 0; }