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

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

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

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

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

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

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

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

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