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

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

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

e = A("e")
h = B("h")
a = C("a")
m = A("m")
j = B("j")

e.o = a
e.v = h
h.p = j
h.v = j
a.x = e
m.o = a
m.v = j
j.p = h
j.v = h
assert m.v.v.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: B = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
a = C("a")
m = A("m")
j = B("j")

e.o = a
e.v = h
h.p = j
h.v = j
a.x = e
m.o = a
m.v = j
j.p = h
j.v = h
assert m.v.v.v.p.v.txt == "j"