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

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

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

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

c = A("c")
m = B("m")
b = C("b")
a = D("a")
d = C("d")
h = B("h")

c.x = h
c.q = d
m.o = h
m.s = h
m.q = d
m.z = d
b.t = m
b.z = d
a.s = m
a.p = h
d.t = h
d.z = b
h.o = m
h.s = m
h.q = d
h.z = d
assert h.z.t.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
b = C("b")
a = D("a")
d = C("d")
h = B("h")

c.x = h
c.q = d
m.o = h
m.s = h
m.q = d
m.z = d
b.t = m
b.z = d
a.s = m
a.p = h
d.t = h
d.z = b
h.o = m
h.s = m
h.q = d
h.z = d
assert h.z.t.o.s.txt == "h"