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

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

i = A("i")
k = B("k")
f = C("f")
d = D("d")
g = C("g")
e = A("e")
n = D("n")
j = C("j")
m = A("m")
a = C("a")

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

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

i = A("i")
k = B("k")
f = C("f")
d = D("d")
g = C("g")
e = A("e")
n = D("n")
j = C("j")
m = A("m")
a = C("a")

i.x = j
i.t = e
k.o = j
f.x = n
d.o = a
g.x = n
e.x = f
e.t = m
n.o = j
j.x = n
m.x = g
m.t = e
a.x = n
assert m.t.t.x.x.o.x.o.x.o.txt == "j"