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

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

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

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

k = A("k")
l = B("l")
h = C("h")
m = D("m")

k.p = h
k.v = m
k.y = l
l.s = h
l.x = h
h.w = m
m.x = k
assert k.y.s.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: D = None
        self.y: B = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
h = C("h")
m = D("m")

k.p = h
k.v = m
k.y = l
l.s = h
l.x = h
h.w = m
m.x = k
assert k.y.s.w.x.txt == "k"