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

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

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

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

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

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

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

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

m.r = l
l.y = b
b.r = e
b.v = a
b.x = a
e.r = b
e.v = a
e.x = m
a.r = l
assert l.y.v.r.y.txt == "b"