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

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

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

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

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

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

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

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

f.p = j
f.u = h
f.x = d
k.t = i
k.q = m
k.u = b
d.y = k
d.z = a
b.p = f
b.u = h
b.x = a
h.y = i
h.z = a
e.p = m
e.u = d
e.x = h
j.p = b
j.u = h
j.x = h
a.y = i
a.z = d
m.p = f
m.u = a
m.x = h
i.t = k
i.q = b
i.u = m
assert m.x.y.q.u.z.y.t.q.p.x.txt == "d"