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

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

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

n = A("n")
i = B("i")
a = C("a")
l = C("l")
d = C("d")
e = B("e")

n.x = e
n.r = l
i.p = e
i.q = a
a.q = e
l.q = i
d.q = e
e.p = i
e.q = l
assert a.q.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: C = None
        self.txt = txt

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

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

n = A("n")
i = B("i")
a = C("a")
l = C("l")
d = C("d")
e = B("e")

n.x = e
n.r = l
i.p = e
i.q = a
a.q = e
l.q = i
d.q = e
e.p = i
e.q = l
assert a.q.p.q.q.txt == "e"