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

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

c = A("c")
k = B("k")
b = A("b")
f = A("f")
j = A("j")
d = A("d")
e = A("e")
i = B("i")
n = A("n")
g = A("g")

c.y = i
k.v = g
b.y = k
f.y = k
j.y = i
d.y = i
e.y = k
i.v = n
n.y = i
g.y = k
assert d.y.v.y.v.y.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

c = A("c")
k = B("k")
b = A("b")
f = A("f")
j = A("j")
d = A("d")
e = A("e")
i = B("i")
n = A("n")
g = A("g")

c.y = i
k.v = g
b.y = k
f.y = k
j.y = i
d.y = i
e.y = k
i.v = n
n.y = i
g.y = k
assert d.y.v.y.v.y.v.y.v.txt == "n"