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

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

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

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

m = A("m")
h = B("h")
d = C("d")
a = D("a")
i = B("i")
g = A("g")
k = D("k")

m.q = k
m.x = k
m.w = a
h.u = i
d.w = k
a.o = h
a.t = h
a.s = i
i.u = h
g.q = a
g.x = a
g.w = a
k.o = i
k.s = i
k.t = i
assert g.q.s.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: D = None
        self.w: D = None
        self.txt = txt

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

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

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

m = A("m")
h = B("h")
d = C("d")
a = D("a")
i = B("i")
g = A("g")
k = D("k")

m.q = k
m.x = k
m.w = a
h.u = i
d.w = k
a.o = h
a.t = h
a.s = i
i.u = h
g.q = a
g.x = a
g.w = a
k.o = i
k.s = i
k.t = i
assert g.q.s.u.u.txt == "i"