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

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

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

e = A("e")
l = B("l")
i = C("i")
d = C("d")
m = B("m")

e.t = i
e.x = i
e.r = m
l.p = e
i.u = d
i.v = m
i.x = l
d.u = i
d.v = l
d.x = m
m.p = e
assert i.v.p.x.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: C = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
i = C("i")
d = C("d")
m = B("m")

e.t = i
e.x = i
e.r = m
l.p = e
i.u = d
i.v = m
i.x = l
d.u = i
d.v = l
d.x = m
m.p = e
assert i.v.p.x.x.p.txt == "e"