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

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

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

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

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

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

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

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

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

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

a.p = k
a.o = k
a.t = d
m.q = e
m.z = e
m.p = d
e.o = m
e.z = d
e.x = a
e.u = k
d.w = e
h.q = e
h.z = e
h.p = d
k.p = a
k.o = a
k.t = d
g.q = e
g.z = e
g.p = d
assert m.p.w.u.txt == "k"