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

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

l = A("l")
a = B("a")
d = B("d")
f = B("f")
i = B("i")
b = B("b")
j = B("j")
e = A("e")

l.x = e
l.s = b
a.x = e
a.q = f
d.x = l
d.q = a
f.x = e
f.q = d
i.x = l
i.q = a
b.x = e
b.q = a
j.x = e
j.q = a
e.x = l
e.s = f
assert i.q.x.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: B = None
        self.txt = txt

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

l = A("l")
a = B("a")
d = B("d")
f = B("f")
i = B("i")
b = B("b")
j = B("j")
e = A("e")

l.x = e
l.s = b
a.x = e
a.q = f
d.x = l
d.q = a
f.x = e
f.q = d
i.x = l
i.q = a
b.x = e
b.q = a
j.x = e
j.q = a
e.x = l
e.s = f
assert i.q.x.x.s.x.txt == "e"