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

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

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

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

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

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

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

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

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