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

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

e = A("e")
d = B("d")
j = B("j")
k = A("k")
f = A("f")
g = B("g")
h = A("h")
c = A("c")
a = A("a")

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

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

e = A("e")
d = B("d")
j = B("j")
k = A("k")
f = A("f")
g = B("g")
h = A("h")
c = A("c")
a = A("a")

e.u = c
e.r = j
d.o = k
j.o = e
k.u = c
k.r = g
f.u = h
f.r = j
g.o = k
h.u = a
h.r = g
c.u = f
c.r = d
a.u = k
a.r = g
assert g.o.u.r.o.u.u.r.txt == "j"