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

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

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

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

i = A("i")
l = B("l")
n = C("n")
h = D("h")

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

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

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

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

i = A("i")
l = B("l")
n = C("n")
h = D("h")

i.u = n
i.s = n
i.r = h
l.z = i
n.u = h
n.y = i
h.p = l
assert i.r.p.z.txt == "i"