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

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

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

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

j = A("j")
h = B("h")
b = C("b")
n = D("n")

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

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

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

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

j = A("j")
h = B("h")
b = C("b")
n = D("n")

j.v = h
j.u = h
j.p = n
j.s = b
h.s = j
h.v = j
h.r = n
b.y = j
b.z = h
n.s = b
assert h.r.s.y.p.txt == "n"