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

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

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

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

k = A("k")
m = B("m")
h = C("h")
i = D("i")
n = C("n")
b = C("b")
c = A("c")
d = C("d")

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

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

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

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

k = A("k")
m = B("m")
h = C("h")
i = D("i")
n = C("n")
b = C("b")
c = A("c")
d = C("d")

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