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

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

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

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

d.s = b
i.t = l
i.z = d
l.u = n
e.s = d
g.t = l
g.z = n
n.s = e
c.t = f
c.z = n
f.u = n
b.s = n
assert g.t.u.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

d.s = b
i.t = l
i.z = d
l.u = n
e.s = d
g.t = l
g.z = n
n.s = e
c.t = f
c.z = n
f.u = n
b.s = n
assert g.t.u.s.s.s.s.txt == "n"