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

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

k = A("k")
l = B("l")
i = B("i")
a = A("a")
g = A("g")
e = A("e")
h = A("h")

k.u = l
k.x = l
l.z = i
l.r = g
i.z = l
i.r = h
a.u = i
a.x = l
g.u = i
g.x = l
e.u = l
e.x = l
h.u = i
h.x = i
assert e.x.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

k = A("k")
l = B("l")
i = B("i")
a = A("a")
g = A("g")
e = A("e")
h = A("h")

k.u = l
k.x = l
l.z = i
l.r = g
i.z = l
i.r = h
a.u = i
a.x = l
g.u = i
g.x = l
e.u = l
e.x = l
h.u = i
h.x = i
assert e.x.z.z.z.z.z.txt == "i"