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

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

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

g = A("g")
b = B("b")
i = C("i")

g.p = b
g.x = i
b.v = i
b.r = g
b.z = g
i.w = b
assert g.x.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
i = C("i")

g.p = b
g.x = i
b.v = i
b.r = g
b.z = g
i.w = b
assert g.x.w.v.txt == "i"