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

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

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

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

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

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

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

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

b.p = d
b.r = d
b.z = g
a.t = d
a.q = d
a.w = g
d.y = b
g.p = d
g.r = d
g.z = b
assert b.z.z.r.txt == "d"