#include<cstdio>
#include<cstring>
#include<cmath>
#define check(i) i-p[0] && i-p[1] && i-p[2]
int p[3],m[3],t[3],ans,dep;
bool f[48][48][48][8][8];
void dfs(int *p,int x,int y)
{
bool &res=f[p[0]][p[1]][p[2]][x][y]; if (res) return; res=1;
int far=0,near=50;
for (int i=0;i<3;i++){
if (p[i]<45 && p[i]>far) far=p[i];
if (p[i]<near) near=p[i];
}
if (far>ans) ans=far;
for (int j=0;j<3;j++) {
int q[3]={p[0],p[1],p[2]},z=1<<j;
if (p[j]>=45){
int T=p[j]-45;
for (int i=p[T]+t[T];p[T]<45 && i>=p[T]-t[T] && i>near-2 && i;i--)
if (check(i)) q[j]=i,dfs(q,x,y);
}
else if (check(j+45)){
if (y&z) for (int i=0;i<3;i++) if (fabs(p[i]-p[j])==1)
q[i]=45+j,dfs(q,x,y^z),q[i]=p[i];
if (x&z) for (int i=p[j]+m[j];i>=p[j]-m[j] && i>near-2 && i;i--)
if (check(i)) q[j]=i,dfs(q,x^z,y);
}
}
}
int main()
{
for (int i=0;i<3;i++) scanf("%d%d%d",p+i,m+i,t+i);
dfs(p,7,7); printf("%d\n",ans); return 0;
}
1353D - Constructing the Array | 1269C - Long Beautiful Integer |
1076A - Minimizing the String | 913C - Party Lemonade |
1313A - Fast Food Restaurant | 681A - A Good Contest |
1585F - Non-equal Neighbours | 747A - Display Size |
285A - Slightly Decreasing Permutations | 515C - Drazil and Factorial |
1151E - Number of Components | 1151F - Sonya and Informatics |
556A - Case of the Zeros and Ones | 867A - Between the Offices |
1569A - Balanced Substring | 260A - Adding Digits |
1698C - 3SUM Closure | 1029B - Creating the Contest |
1421A - XORwice | 1029A - Many Equal Substrings |
1675D - Vertical Paths | 1271C - Shawarma Tent |
805A - Fake NP | 1163A - Eating Soup |
787A - The Monster | 807A - Is it rated |
1096A - Find Divisible | 1430C - Numbers on Whiteboard |
1697B - Promo | 208D - Prizes Prizes more Prizes |