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

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

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

f.x = d
j.q = g
j.x = i
i.x = d
g.q = e
g.x = i
e.q = k
e.x = f
h.q = j
h.x = l
d.x = l
k.q = e
k.x = l
l.x = f
assert i.x.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

f.x = d
j.q = g
j.x = i
i.x = d
g.q = e
g.x = i
e.q = k
e.x = f
h.q = j
h.x = l
d.x = l
k.q = e
k.x = l
l.x = f
assert i.x.x.x.x.x.x.x.x.x.txt == "f"