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

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

d = A("d")
j = B("j")
h = A("h")

d.v = h
d.t = j
j.y = d
h.v = d
h.t = j
assert d.v.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

d = A("d")
j = B("j")
h = A("h")

d.v = h
d.t = j
j.y = d
h.v = d
h.t = j
assert d.v.t.y.txt == "d"