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

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

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

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

l.v = i
l.r = e
l.x = j
a.p = c
e.s = j
m.p = a
j.s = e
c.p = m
i.v = l
i.r = e
i.x = j
assert i.x.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: C = None
        self.x: C = None
        self.txt = txt

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

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

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

l.v = i
l.r = e
l.x = j
a.p = c
e.s = j
m.p = a
j.s = e
c.p = m
i.v = l
i.r = e
i.x = j
assert i.x.s.s.s.txt == "e"