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

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

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

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

f = A("f")
j = B("j")
k = C("k")
c = D("c")
g = D("g")
e = A("e")
h = C("h")
a = D("a")
m = B("m")
i = B("i")

f.s = c
j.q = i
j.r = h
j.u = h
k.q = h
k.o = j
c.z = f
g.z = f
e.s = g
h.q = k
h.o = m
a.z = f
m.q = i
m.r = h
m.u = k
i.q = m
i.r = h
i.u = k
assert e.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
k = C("k")
c = D("c")
g = D("g")
e = A("e")
h = C("h")
a = D("a")
m = B("m")
i = B("i")

f.s = c
j.q = i
j.r = h
j.u = h
k.q = h
k.o = j
c.z = f
g.z = f
e.s = g
h.q = k
h.o = m
a.z = f
m.q = i
m.r = h
m.u = k
i.q = m
i.r = h
i.u = k
assert e.s.z.s.z.txt == "f"