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

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

g = A("g")
j = B("j")
n = B("n")
i = B("i")
k = B("k")
e = A("e")
c = A("c")
b = B("b")

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

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

g = A("g")
j = B("j")
n = B("n")
i = B("i")
k = B("k")
e = A("e")
c = A("c")
b = B("b")

g.q = c
g.o = e
j.u = b
n.u = b
i.u = j
k.u = j
e.q = c
e.o = c
c.q = g
c.o = e
b.u = n
assert e.o.q.q.q.q.txt == "c"