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

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

g = A("g")
d = B("d")
e = A("e")
i = B("i")
a = A("a")
j = B("j")
c = A("c")
k = B("k")

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

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

g = A("g")
d = B("d")
e = A("e")
i = B("i")
a = A("a")
j = B("j")
c = A("c")
k = B("k")

g.v = j
d.x = k
e.v = j
i.x = j
a.v = d
j.x = k
c.v = d
k.x = j
assert c.v.x.x.x.txt == "k"