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

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

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

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

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

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

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

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

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