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

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

b = A("b")
n = B("n")
a = B("a")
d = B("d")
j = A("j")

b.w = a
b.t = j
n.v = a
a.v = d
d.v = a
j.w = n
j.t = b
assert b.w.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: A = None
        self.txt = txt

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

b = A("b")
n = B("n")
a = B("a")
d = B("d")
j = A("j")

b.w = a
b.t = j
n.v = a
a.v = d
d.v = a
j.w = n
j.t = b
assert b.w.v.v.txt == "a"