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

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

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

l = A("l")
c = B("c")
n = C("n")
k = A("k")
d = C("d")
a = B("a")

l.p = d
l.t = n
c.x = k
c.u = k
n.z = k
k.p = d
k.t = d
d.z = k
a.x = k
a.u = k
assert n.z.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
n = C("n")
k = A("k")
d = C("d")
a = B("a")

l.p = d
l.t = n
c.x = k
c.u = k
n.z = k
k.p = d
k.t = d
d.z = k
a.x = k
a.u = k
assert n.z.p.z.p.txt == "d"