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

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

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

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

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

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

d.q = i
e.o = d
j.q = i
k.o = i
f.q = i
n.o = d
i.q = d
l.o = j
b.o = d
assert d.q.q.q.q.txt == "d"