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

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

e = A("e")
f = B("f")
h = A("h")
k = A("k")
c = B("c")
i = A("i")
a = A("a")
b = B("b")

e.q = k
e.x = c
f.u = k
f.s = c
h.q = i
h.x = c
k.q = a
k.x = b
c.u = k
c.s = f
i.q = h
i.x = b
a.q = i
a.x = f
b.u = a
b.s = c
assert e.x.s.s.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.txt = txt

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

e = A("e")
f = B("f")
h = A("h")
k = A("k")
c = B("c")
i = A("i")
a = A("a")
b = B("b")

e.q = k
e.x = c
f.u = k
f.s = c
h.q = i
h.x = c
k.q = a
k.x = b
c.u = k
c.s = f
i.q = h
i.x = b
a.q = i
a.x = f
b.u = a
b.s = c
assert e.x.s.s.u.x.txt == "b"