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

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

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

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

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

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

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

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

a.y = j
a.v = e
a.s = m
j.s = m
b.z = a
m.s = j
e.y = m
e.s = m
e.v = a
assert m.s.s.s.txt == "j"