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

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

i = A("i")
g = B("g")
a = B("a")
d = A("d")

i.v = g
g.s = a
a.s = g
d.v = g
assert d.v.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

i = A("i")
g = B("g")
a = B("a")
d = A("d")

i.v = g
g.s = a
a.s = g
d.v = g
assert d.v.s.s.s.txt == "a"