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

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

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

k = A("k")
g = B("g")
d = C("d")
l = A("l")

k.v = d
k.w = d
k.x = l
g.p = d
d.s = g
d.r = l
l.v = d
l.w = d
l.x = k
assert d.s.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.x: A = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
d = C("d")
l = A("l")

k.v = d
k.w = d
k.x = l
g.p = d
d.s = g
d.r = l
l.v = d
l.w = d
l.x = k
assert d.s.p.r.txt == "l"