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

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

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

a = A("a")
j = B("j")
b = C("b")
i = C("i")
m = A("m")
e = A("e")

a.v = m
a.p = j
a.x = j
j.y = i
j.u = m
b.v = e
i.v = e
m.v = e
m.p = j
m.x = j
e.v = a
e.p = j
e.x = j
assert i.v.v.x.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: B = None
        self.x: B = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
b = C("b")
i = C("i")
m = A("m")
e = A("e")

a.v = m
a.p = j
a.x = j
j.y = i
j.u = m
b.v = e
i.v = e
m.v = e
m.p = j
m.x = j
e.v = a
e.p = j
e.x = j
assert i.v.v.x.y.v.txt == "e"