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

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

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

k = A("k")
d = B("d")
e = C("e")
j = B("j")
m = C("m")

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

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

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

k = A("k")
d = B("d")
e = C("e")
j = B("j")
m = C("m")

k.x = d
d.x = k
d.v = k
d.y = j
e.y = k
e.w = k
e.v = d
j.x = k
j.v = k
j.y = d
m.y = k
m.w = k
m.v = j
assert d.x.x.y.v.txt == "k"