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

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

k = A("k")
e = B("e")
n = A("n")
f = B("f")
g = A("g")
h = A("h")

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

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

k = A("k")
e = B("e")
n = A("n")
f = B("f")
g = A("g")
h = A("h")

k.y = f
k.v = f
e.x = k
e.z = f
n.y = e
n.v = e
f.x = k
f.z = e
g.y = e
g.v = f
h.y = e
h.v = e
assert e.x.y.z.x.txt == "k"