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

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

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

n = A("n")
g = B("g")
j = C("j")
e = B("e")
i = A("i")
b = B("b")

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

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

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

n = A("n")
g = B("g")
j = C("j")
e = B("e")
i = A("i")
b = B("b")

n.v = j
n.y = i
g.p = e
g.o = n
j.v = e
j.o = i
e.p = g
e.o = n
i.v = j
i.y = n
b.p = e
b.o = n
assert n.v.o.v.o.v.txt == "j"