class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: B = None
        self.txt = txt

j = A("j")
l = B("l")
g = A("g")
f = B("f")
e = A("e")
m = A("m")
n = B("n")
h = B("h")

j.s = l
j.t = l
l.u = f
l.r = n
g.s = l
g.t = f
f.u = n
f.r = h
e.s = l
e.t = h
m.s = h
m.t = n
n.u = l
n.r = l
h.u = l
h.r = f
assert m.t.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: B = None
        self.txt = txt

j = A("j")
l = B("l")
g = A("g")
f = B("f")
e = A("e")
m = A("m")
n = B("n")
h = B("h")

j.s = l
j.t = l
l.u = f
l.r = n
g.s = l
g.t = f
f.u = n
f.r = h
e.s = l
e.t = h
m.s = h
m.t = n
n.u = l
n.r = l
h.u = l
h.r = f
assert m.t.u.u.txt == "f"