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

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

e = A("e")
n = B("n")
i = B("i")
c = A("c")
j = A("j")
f = A("f")

e.s = n
e.q = f
n.t = j
i.t = j
c.s = n
c.q = f
j.s = n
j.q = e
f.s = i
f.q = j
assert i.t.s.t.q.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: A = None
        self.txt = txt

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

e = A("e")
n = B("n")
i = B("i")
c = A("c")
j = A("j")
f = A("f")

e.s = n
e.q = f
n.t = j
i.t = j
c.s = n
c.q = f
j.s = n
j.q = e
f.s = i
f.q = j
assert i.t.s.t.q.q.s.txt == "i"