import std.stdio; import std.string; import std.conv; import std.math; void main(){ auto T = readln.chomp.to!int; for(auto t = 0; t < T; t++){ auto s = readln.chomp.split.to!(int[]); int a,b,c,d; if(s[0] < s[1]){ a = s[0]; b = s[1]; c = s[2]; d = s[3]; }else{ a = s[1]; b = s[0]; c = s[3]; d = s[2]; } if(b <= d){ if(c < d){ if(a <= c){ writeln((d - b) + (c - a)); }else{ writeln((d - b) + (1 + c)); } }else{ writeln((c - a) + (1 + d)); } }else{ if(c < d){ if(a == 1){ writeln((1 + d) + (1 + c) + 1); }else{ writeln((1 + d) + (1 + c)); } }else{ if(a <= c){ writeln((1 + d) + (c - a)); }else{ writeln((1 + d) + (1 + c)); } } } } }