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

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

j = A("j")
b = B("b")
h = B("h")
g = A("g")
d = A("d")
f = B("f")
a = B("a")
k = A("k")
i = B("i")
e = A("e")

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

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

j = A("j")
b = B("b")
h = B("h")
g = A("g")
d = A("d")
f = B("f")
a = B("a")
k = A("k")
i = B("i")
e = A("e")

j.z = a
j.v = f
b.y = a
b.x = j
h.y = a
h.x = e
g.z = h
g.v = i
d.z = a
d.v = f
f.y = h
f.x = e
a.y = f
a.x = e
k.z = f
k.v = f
i.y = a
i.x = e
e.z = a
e.v = a
assert d.z.y.y.y.y.y.x.v.y.txt == "f"