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

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

k = A("k")
j = B("j")
e = B("e")
g = B("g")

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

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

k = A("k")
j = B("j")
e = B("e")
g = B("g")

k.r = g
j.v = e
j.w = e
e.v = g
e.w = j
g.v = e
g.w = e
assert j.w.v.w.txt == "e"