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

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

n = A("n")
h = B("h")
a = B("a")
b = B("b")
j = A("j")
f = B("f")

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

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

n = A("n")
h = B("h")
a = B("a")
b = B("b")
j = A("j")
f = B("f")

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