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

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

j = A("j")
n = B("n")
i = B("i")
c = A("c")
a = B("a")
f = A("f")
l = B("l")
e = A("e")

j.r = f
j.z = f
n.s = i
n.u = j
i.s = l
i.u = f
c.r = j
c.z = j
a.s = n
a.u = c
f.r = j
f.z = c
l.s = a
l.u = f
e.r = f
e.z = j
assert e.r.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: A = None
        self.txt = txt

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

j = A("j")
n = B("n")
i = B("i")
c = A("c")
a = B("a")
f = A("f")
l = B("l")
e = A("e")

j.r = f
j.z = f
n.s = i
n.u = j
i.s = l
i.u = f
c.r = j
c.z = j
a.s = n
a.u = c
f.r = j
f.z = c
l.s = a
l.u = f
e.r = f
e.z = j
assert e.r.z.z.txt == "j"