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

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

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

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

d.w = l
d.y = c
a.s = d
a.t = i
a.o = c
i.p = l
i.q = c
l.p = i
l.q = a
c.s = d
c.t = l
c.o = a
assert d.y.o.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

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

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

d.w = l
d.y = c
a.s = d
a.t = i
a.o = c
i.p = l
i.q = c
l.p = i
l.q = a
c.s = d
c.t = l
c.o = a
assert d.y.o.t.p.txt == "l"