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

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

c = A("c")
b = B("b")
l = A("l")
h = A("h")
j = A("j")
i = B("i")
f = A("f")
d = A("d")
g = A("g")
k = A("k")

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

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

c = A("c")
b = B("b")
l = A("l")
h = A("h")
j = A("j")
i = B("i")
f = A("f")
d = A("d")
g = A("g")
k = A("k")

c.z = l
c.r = k
b.o = i
l.z = f
l.r = h
h.z = j
h.r = f
j.z = l
j.r = l
i.o = b
f.z = c
f.r = j
d.z = l
d.r = l
g.z = h
g.r = d
k.z = j
k.r = h
assert d.r.r.z.r.txt == "l"