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

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

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

j = A("j")
b = B("b")
k = C("k")
d = A("d")

j.y = d
j.x = d
b.v = k
b.w = k
k.z = b
d.y = j
d.x = j
assert b.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: A = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
k = C("k")
d = A("d")

j.y = d
j.x = d
b.v = k
b.w = k
k.z = b
d.y = j
d.x = j
assert b.w.z.w.txt == "k"