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

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

c = A("c")
b = B("b")
n = B("n")
l = B("l")
f = A("f")

c.v = l
b.y = f
b.w = n
n.y = f
n.w = l
l.y = f
l.w = b
f.v = l
assert l.y.v.y.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

c = A("c")
b = B("b")
n = B("n")
l = B("l")
f = A("f")

c.v = l
b.y = f
b.w = n
n.y = f
n.w = l
l.y = f
l.w = b
f.v = l
assert l.y.v.y.v.w.txt == "b"