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

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

j = A("j")
k = B("k")
n = A("n")
i = B("i")
a = A("a")
b = A("b")
d = A("d")
f = B("f")
e = B("e")
g = B("g")

j.r = g
j.z = i
k.y = e
k.u = f
n.r = i
n.z = f
i.y = g
i.u = k
a.r = e
a.z = f
b.r = g
b.z = i
d.r = k
d.z = f
f.y = i
f.u = k
e.y = g
e.u = g
g.y = e
g.u = e
assert f.y.y.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.txt = txt

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

j = A("j")
k = B("k")
n = A("n")
i = B("i")
a = A("a")
b = A("b")
d = A("d")
f = B("f")
e = B("e")
g = B("g")

j.r = g
j.z = i
k.y = e
k.u = f
n.r = i
n.z = f
i.y = g
i.u = k
a.r = e
a.z = f
b.r = g
b.z = i
d.r = k
d.z = f
f.y = i
f.u = k
e.y = g
e.u = g
g.y = e
g.u = e
assert f.y.y.u.y.u.txt == "e"