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

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

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

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

h = A("h")
f = B("f")
j = C("j")
l = D("l")
i = D("i")
e = A("e")

h.w = j
h.u = f
h.p = i
f.u = j
j.o = f
l.y = j
i.y = j
e.w = j
e.u = f
e.p = l
assert l.y.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: B = None
        self.p: D = None
        self.txt = txt

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

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

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

h = A("h")
f = B("f")
j = C("j")
l = D("l")
i = D("i")
e = A("e")

h.w = j
h.u = f
h.p = i
f.u = j
j.o = f
l.y = j
i.y = j
e.w = j
e.u = f
e.p = l
assert l.y.o.u.txt == "j"