class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: D = None
        self.z: C = 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.t: B = None
        self.q: B = None
        self.txt = txt

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

l = A("l")
d = B("d")
h = C("h")
m = D("m")
f = D("f")

l.o = f
l.q = f
l.z = h
d.u = h
h.t = d
h.q = d
m.u = l
m.s = l
m.v = l
m.o = d
f.u = l
f.s = l
f.v = l
f.o = d
assert m.o.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: D = None
        self.z: C = 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.t: B = None
        self.q: B = None
        self.txt = txt

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

l = A("l")
d = B("d")
h = C("h")
m = D("m")
f = D("f")

l.o = f
l.q = f
l.z = h
d.u = h
h.t = d
h.q = d
m.u = l
m.s = l
m.v = l
m.o = d
f.u = l
f.s = l
f.v = l
f.o = d
assert m.o.u.t.u.txt == "h"