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

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

g = A("g")
j = B("j")
i = B("i")

g.v = j
g.z = j
j.v = i
i.v = j
assert j.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
i = B("i")

g.v = j
g.z = j
j.v = i
i.v = j
assert j.v.v.v.txt == "i"