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

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

l = A("l")
g = B("g")
h = B("h")
k = A("k")
b = B("b")
f = A("f")
n = B("n")
e = A("e")
a = B("a")
c = B("c")

l.v = k
g.w = n
h.w = g
k.v = e
b.w = c
f.v = e
n.w = c
e.v = k
a.w = n
c.w = b
assert k.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.w: B = None
        self.txt = txt

l = A("l")
g = B("g")
h = B("h")
k = A("k")
b = B("b")
f = A("f")
n = B("n")
e = A("e")
a = B("a")
c = B("c")

l.v = k
g.w = n
h.w = g
k.v = e
b.w = c
f.v = e
n.w = c
e.v = k
a.w = n
c.w = b
assert k.v.v.v.v.txt == "k"