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

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

c = A("c")
h = B("h")
a = A("a")
f = A("f")

c.v = a
h.y = f
h.w = a
a.v = f
f.v = a
assert a.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

c = A("c")
h = B("h")
a = A("a")
f = A("f")

c.v = a
h.y = f
h.w = a
a.v = f
f.v = a
assert a.v.v.v.v.txt == "a"