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

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

c = A("c")
b = B("b")
l = B("l")
g = B("g")

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

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

c = A("c")
b = B("b")
l = B("l")
g = B("g")

c.x = l
c.r = l
b.v = g
b.t = l
l.v = b
l.t = g
g.v = l
g.t = b
assert g.t.t.v.txt == "b"