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

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

d = A("d")
n = B("n")
j = B("j")
i = B("i")
c = B("c")
b = B("b")

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

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

d = A("d")
n = B("n")
j = B("j")
i = B("i")
c = B("c")
b = B("b")

d.v = j
n.w = j
j.w = n
i.w = b
c.w = n
b.w = i
assert b.w.w.w.w.txt == "b"