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

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

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

b = A("b")
e = B("e")
a = C("a")
j = C("j")
i = B("i")
f = A("f")
c = A("c")
k = C("k")
n = A("n")

b.y = e
e.p = k
a.o = i
a.u = c
j.o = e
j.u = f
i.p = a
f.y = i
c.y = e
k.o = e
k.u = f
n.y = i
assert f.y.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

b = A("b")
e = B("e")
a = C("a")
j = C("j")
i = B("i")
f = A("f")
c = A("c")
k = C("k")
n = A("n")

b.y = e
e.p = k
a.o = i
a.u = c
j.o = e
j.u = f
i.p = a
f.y = i
c.y = e
k.o = e
k.u = f
n.y = i
assert f.y.p.o.txt == "i"