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

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

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

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

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

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

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

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

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

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

h.u = i
h.o = j
f.y = l
f.o = l
f.t = e
i.z = e
j.x = i
j.q = i
j.w = f
j.s = f
e.y = h
e.o = h
e.t = f
l.u = i
l.o = j
assert j.w.t.o.u.z.txt == "e"