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

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

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

e.r = i
e.p = c
n.q = i
n.w = c
c.r = i
c.p = a
i.q = n
i.w = c
j.q = n
j.w = c
a.r = n
a.p = c
assert j.w.r.q.w.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: A = None
        self.txt = txt

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

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

e.r = i
e.p = c
n.q = i
n.w = c
c.r = i
c.p = a
i.q = n
i.w = c
j.q = n
j.w = c
a.r = n
a.p = c
assert j.w.r.q.w.r.q.txt == "n"