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

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

c = A("c")
m = B("m")
k = B("k")
e = B("e")

c.w = e
m.r = e
m.v = c
k.r = m
k.v = c
e.r = m
e.v = c
assert e.v.w.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

c = A("c")
m = B("m")
k = B("k")
e = B("e")

c.w = e
m.r = e
m.v = c
k.r = m
k.v = c
e.r = m
e.v = c
assert e.v.w.r.r.txt == "e"