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

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

g = A("g")
j = B("j")
n = B("n")
a = A("a")
k = A("k")
f = B("f")
l = B("l")
e = A("e")

g.u = f
g.r = j
j.o = e
n.o = g
a.u = n
a.r = n
k.u = l
k.r = j
f.o = k
l.o = g
e.u = l
e.r = j
assert g.u.o.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
n = B("n")
a = A("a")
k = A("k")
f = B("f")
l = B("l")
e = A("e")

g.u = f
g.r = j
j.o = e
n.o = g
a.u = n
a.r = n
k.u = l
k.r = j
f.o = k
l.o = g
e.u = l
e.r = j
assert g.u.o.r.o.r.txt == "j"