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

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

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

b = A("b")
d = B("d")
k = C("k")
n = B("n")
g = A("g")
h = B("h")
c = B("c")
j = C("j")
f = C("f")

b.p = h
b.s = g
d.t = k
d.q = b
k.u = h
k.x = j
k.z = j
n.t = k
n.q = g
g.p = d
g.s = b
h.t = k
h.q = b
c.t = k
c.q = b
j.u = c
j.x = f
j.z = f
f.u = c
f.x = k
f.z = k
assert f.x.z.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: A = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
k = C("k")
n = B("n")
g = A("g")
h = B("h")
c = B("c")
j = C("j")
f = C("f")

b.p = h
b.s = g
d.t = k
d.q = b
k.u = h
k.x = j
k.z = j
n.t = k
n.q = g
g.p = d
g.s = b
h.t = k
h.q = b
c.t = k
c.q = b
j.u = c
j.x = f
j.z = f
f.u = c
f.x = k
f.z = k
assert f.x.z.z.u.txt == "c"