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

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

c = A("c")
a = B("a")
j = B("j")
f = A("f")
b = A("b")
e = B("e")
l = B("l")
k = A("k")
h = A("h")
i = B("i")

c.x = h
c.p = k
a.s = e
a.q = l
j.s = i
j.q = a
f.x = h
f.p = k
b.x = k
b.p = c
e.s = l
e.q = a
l.s = a
l.q = i
k.x = h
k.p = c
h.x = f
h.p = b
i.s = j
i.q = a
assert j.q.q.q.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: A = None
        self.txt = txt

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

c = A("c")
a = B("a")
j = B("j")
f = A("f")
b = A("b")
e = B("e")
l = B("l")
k = A("k")
h = A("h")
i = B("i")

c.x = h
c.p = k
a.s = e
a.q = l
j.s = i
j.q = a
f.x = h
f.p = k
b.x = k
b.p = c
e.s = l
e.q = a
l.s = a
l.q = i
k.x = h
k.p = c
h.x = f
h.p = b
i.s = j
i.q = a
assert j.q.q.q.q.s.txt == "e"