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

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

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

l = A("l")
i = B("i")
m = C("m")
d = B("d")
b = B("b")
c = A("c")

l.r = i
i.x = d
i.y = m
i.t = l
m.s = i
m.v = i
d.x = b
d.y = m
d.t = c
b.x = i
b.y = m
b.t = c
c.r = i
assert l.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
m = C("m")
d = B("d")
b = B("b")
c = A("c")

l.r = i
i.x = d
i.y = m
i.t = l
m.s = i
m.v = i
d.x = b
d.y = m
d.t = c
b.x = i
b.y = m
b.t = c
c.r = i
assert l.r.t.r.txt == "i"