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

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

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

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

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

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

d.x = k
d.y = e
j.v = k
b.v = k
e.v = a
n.x = c
n.y = j
g.v = n
a.x = n
a.y = j
c.x = a
c.y = b
k.x = a
k.y = b
assert e.v.x.x.x.y.v.x.y.v.txt == "k"