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

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

a = A("a")
f = B("f")
k = B("k")
j = A("j")
b = A("b")
d = A("d")
l = A("l")

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

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

a = A("a")
f = B("f")
k = B("k")
j = A("j")
b = A("b")
d = A("d")
l = A("l")

a.w = f
f.v = k
k.v = f
j.w = k
b.w = f
d.w = k
l.w = f
assert k.v.v.v.txt == "f"