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

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

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

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

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

m.u = i
i.p = h
h.o = l
l.t = i
l.u = m
l.y = m
assert i.p.o.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

m.u = i
i.p = h
h.o = l
l.t = i
l.u = m
l.y = m
assert i.p.o.t.p.txt == "h"