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

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

d = A("d")
i = B("i")
e = A("e")
j = A("j")
f = B("f")
k = A("k")

d.o = j
d.t = e
i.u = f
i.x = f
e.o = d
e.t = k
j.o = k
j.t = k
f.u = i
f.x = i
k.o = j
k.t = j
assert e.o.t.o.o.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: A = None
        self.txt = txt

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

d = A("d")
i = B("i")
e = A("e")
j = A("j")
f = B("f")
k = A("k")

d.o = j
d.t = e
i.u = f
i.x = f
e.o = d
e.t = k
j.o = k
j.t = k
f.u = i
f.x = i
k.o = j
k.t = j
assert e.o.t.o.o.t.t.txt == "j"