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

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

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

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

b.u = g
n.p = i
n.u = a
d.z = m
d.s = a
e.z = d
e.s = m
i.p = f
i.u = a
h.p = i
h.u = d
g.u = b
f.p = i
f.u = a
a.z = e
a.s = m
m.z = a
m.s = d
assert f.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

b.u = g
n.p = i
n.u = a
d.z = m
d.s = a
e.z = d
e.s = m
i.p = f
i.u = a
h.p = i
h.u = d
g.u = b
f.p = i
f.u = a
a.z = e
a.s = m
m.z = a
m.s = d
assert f.p.p.p.txt == "i"