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: B = None
        self.txt = txt

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

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

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

n.v = b
k.y = n
k.w = g
b.v = n
a.y = n
a.w = k
g.y = n
g.w = a
e.y = n
e.w = k
h.y = n
h.w = g
assert h.w.y.v.v.txt == "n"