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

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

j = A("j")
c = B("c")
a = A("a")
g = A("g")
n = A("n")
l = A("l")
f = B("f")

j.u = c
c.t = f
c.u = f
a.u = f
g.u = f
n.u = c
l.u = c
f.t = c
f.u = c
assert a.u.t.u.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

j = A("j")
c = B("c")
a = A("a")
g = A("g")
n = A("n")
l = A("l")
f = B("f")

j.u = c
c.t = f
c.u = f
a.u = f
g.u = f
n.u = c
l.u = c
f.t = c
f.u = c
assert a.u.t.u.u.t.txt == "f"