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

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

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

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

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

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

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

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

d.w = a
d.q = i
d.y = i
i.t = d
i.p = g
g.y = i
a.w = d
a.q = i
a.y = i
assert a.w.w.w.w.txt == "a"