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

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

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

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

n.v = j
i.o = c
j.p = a
j.y = a
j.v = n
c.o = e
b.v = a
d.v = j
f.v = a
a.p = j
a.y = j
a.v = b
h.v = j
e.o = i
assert a.v.v.p.y.v.v.p.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

n.v = j
i.o = c
j.p = a
j.y = a
j.v = n
c.o = e
b.v = a
d.v = j
f.v = a
a.p = j
a.y = j
a.v = b
h.v = j
e.o = i
assert a.v.v.p.y.v.v.p.v.v.p.txt == "a"