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

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

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

d = A("d")
l = B("l")
k = C("k")
g = A("g")
c = C("c")
f = B("f")
b = C("b")
e = C("e")

d.s = f
d.z = f
l.o = e
l.p = f
k.o = d
k.t = c
g.s = f
g.z = l
c.o = g
c.t = k
f.o = c
f.p = l
b.o = g
b.t = c
e.o = d
e.t = c
assert e.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: B = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
k = C("k")
g = A("g")
c = C("c")
f = B("f")
b = C("b")
e = C("e")

d.s = f
d.z = f
l.o = e
l.p = f
k.o = d
k.t = c
g.s = f
g.z = l
c.o = g
c.t = k
f.o = c
f.p = l
b.o = g
b.t = c
e.o = d
e.t = c
assert e.t.t.t.t.txt == "k"