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

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

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

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

k = A("k")
f = B("f")
h = C("h")
n = D("n")
a = B("a")
m = A("m")
g = B("g")

k.u = n
k.x = n
k.q = h
f.t = h
h.o = n
h.q = g
n.t = h
a.t = h
m.u = n
m.x = n
m.q = h
g.t = h
assert g.t.o.t.q.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: D = None
        self.q: C = None
        self.txt = txt

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

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

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

k = A("k")
f = B("f")
h = C("h")
n = D("n")
a = B("a")
m = A("m")
g = B("g")

k.u = n
k.x = n
k.q = h
f.t = h
h.o = n
h.q = g
n.t = h
a.t = h
m.u = n
m.x = n
m.q = h
g.t = h
assert g.t.o.t.q.t.q.t.txt == "h"