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

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

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

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

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

d.y = k
d.s = k
d.u = a
d.v = h
h.z = a
h.p = a
h.r = l
m.y = b
a.z = l
l.y = a
k.y = d
k.s = d
k.u = b
k.v = h
b.z = l
assert h.p.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: A = None
        self.u: D = None
        self.v: B = None
        self.txt = txt

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

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

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

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

d.y = k
d.s = k
d.u = a
d.v = h
h.z = a
h.p = a
h.r = l
m.y = b
a.z = l
l.y = a
k.y = d
k.s = d
k.u = b
k.v = h
b.z = l
assert h.p.z.y.txt == "a"