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

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

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

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

h = A("h")
n = B("n")
i = C("i")
m = D("m")
d = D("d")
b = D("b")

h.r = i
h.v = n
n.r = h
n.y = h
n.u = b
i.r = d
i.z = b
m.s = h
m.v = h
m.z = d
d.s = h
d.v = h
d.z = b
b.s = h
b.v = h
b.z = m
assert m.s.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

h = A("h")
n = B("n")
i = C("i")
m = D("m")
d = D("d")
b = D("b")

h.r = i
h.v = n
n.r = h
n.y = h
n.u = b
i.r = d
i.z = b
m.s = h
m.v = h
m.z = d
d.s = h
d.v = h
d.z = b
b.s = h
b.v = h
b.z = m
assert m.s.v.y.txt == "h"