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

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

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

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

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

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

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

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

n.o = i
n.p = k
j.v = i
j.o = f
b.u = n
b.p = c
f.v = n
f.o = j
c.u = n
c.p = k
i.o = n
i.p = c
k.u = i
k.p = b
assert b.u.p.p.p.p.u.txt == "i"