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

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

k = A("k")
l = B("l")
j = A("j")
f = A("f")
b = A("b")
d = A("d")
c = B("c")
e = B("e")
i = B("i")
m = A("m")

k.r = j
k.o = j
l.o = m
l.x = d
j.r = d
j.o = k
f.r = b
f.o = b
b.r = m
b.o = d
d.r = k
d.o = b
c.o = k
c.x = k
e.o = b
e.x = d
i.o = d
i.x = b
m.r = b
m.o = j
assert e.x.o.o.o.o.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.txt = txt

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

k = A("k")
l = B("l")
j = A("j")
f = A("f")
b = A("b")
d = A("d")
c = B("c")
e = B("e")
i = B("i")
m = A("m")

k.r = j
k.o = j
l.o = m
l.x = d
j.r = d
j.o = k
f.r = b
f.o = b
b.r = m
b.o = d
d.r = k
d.o = b
c.o = k
c.x = k
e.o = b
e.x = d
i.o = d
i.x = b
m.r = b
m.o = j
assert e.x.o.o.o.o.r.o.r.txt == "d"