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

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

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

n = A("n")
a = B("a")
f = C("f")
i = B("i")
c = C("c")
d = A("d")
b = A("b")
g = B("g")
j = B("j")

n.s = a
n.o = b
n.z = c
a.u = f
f.u = i
f.p = g
i.u = c
c.u = g
c.p = a
d.s = i
d.o = b
d.z = f
b.s = i
b.o = n
b.z = f
g.u = c
j.u = c
assert i.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: A = None
        self.z: C = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
f = C("f")
i = B("i")
c = C("c")
d = A("d")
b = A("b")
g = B("g")
j = B("j")

n.s = a
n.o = b
n.z = c
a.u = f
f.u = i
f.p = g
i.u = c
c.u = g
c.p = a
d.s = i
d.o = b
d.z = f
b.s = i
b.o = n
b.z = f
g.u = c
j.u = c
assert i.u.p.u.txt == "f"