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

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

a = A("a")
e = B("e")
f = B("f")
m = A("m")
l = B("l")
j = B("j")

a.o = f
a.x = j
e.r = a
e.q = f
f.r = m
f.q = j
m.o = j
m.x = l
l.r = a
l.q = e
j.r = m
j.q = l
assert j.r.o.q.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.txt = txt

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

a = A("a")
e = B("e")
f = B("f")
m = A("m")
l = B("l")
j = B("j")

a.o = f
a.x = j
e.r = a
e.q = f
f.r = m
f.q = j
m.o = j
m.x = l
l.r = a
l.q = e
j.r = m
j.q = l
assert j.r.o.q.r.x.txt == "j"