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

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

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

j = A("j")
f = B("f")
n = C("n")
d = A("d")
g = B("g")
e = C("e")

j.t = d
f.p = n
f.z = g
f.y = g
n.o = f
d.t = j
g.p = e
g.z = f
g.y = f
e.o = g
assert e.o.z.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
n = C("n")
d = A("d")
g = B("g")
e = C("e")

j.t = d
f.p = n
f.z = g
f.y = g
n.o = f
d.t = j
g.p = e
g.z = f
g.y = f
e.o = g
assert e.o.z.p.o.p.txt == "n"