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

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

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

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

n = A("n")
d = B("d")
m = C("m")
e = D("e")
f = D("f")
h = B("h")
i = B("i")
a = A("a")
k = B("k")
b = B("b")

n.x = m
d.p = m
d.w = m
m.s = f
m.q = a
m.u = e
m.t = n
e.o = n
e.p = n
f.o = a
f.p = n
h.p = m
h.w = m
i.p = m
i.w = m
a.x = m
k.p = m
k.w = m
b.p = m
b.w = m
assert f.o.x.q.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

n = A("n")
d = B("d")
m = C("m")
e = D("e")
f = D("f")
h = B("h")
i = B("i")
a = A("a")
k = B("k")
b = B("b")

n.x = m
d.p = m
d.w = m
m.s = f
m.q = a
m.u = e
m.t = n
e.o = n
e.p = n
f.o = a
f.p = n
h.p = m
h.w = m
i.p = m
i.w = m
a.x = m
k.p = m
k.w = m
b.p = m
b.w = m
assert f.o.x.q.x.s.txt == "f"