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

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

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

j = A("j")
c = B("c")
f = C("f")
h = C("h")
i = C("i")
a = C("a")
e = B("e")
n = A("n")
l = A("l")
m = B("m")

j.o = h
j.z = m
c.u = m
c.r = m
c.x = n
f.p = n
f.x = a
h.p = l
h.x = a
i.p = l
i.x = a
a.p = j
a.x = f
e.u = c
e.r = c
e.x = j
n.o = i
n.z = c
l.o = h
l.z = c
m.u = c
m.r = e
m.x = l
assert f.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: B = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
f = C("f")
h = C("h")
i = C("i")
a = C("a")
e = B("e")
n = A("n")
l = A("l")
m = B("m")

j.o = h
j.z = m
c.u = m
c.r = m
c.x = n
f.p = n
f.x = a
h.p = l
h.x = a
i.p = l
i.x = a
a.p = j
a.x = f
e.u = c
e.r = c
e.x = j
n.o = i
n.z = c
l.o = h
l.z = c
m.u = c
m.r = e
m.x = l
assert f.x.x.x.x.txt == "f"