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.q: B = None
        self.u: B = None
        self.txt = txt

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

h.r = c
h.z = c
g.q = e
g.u = l
c.r = i
c.z = i
d.r = i
d.z = h
f.q = e
f.u = g
b.q = e
b.u = l
i.r = d
i.z = h
e.q = g
e.u = f
l.q = b
l.u = f
assert c.r.r.r.z.r.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.q: B = None
        self.u: B = None
        self.txt = txt

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

h.r = c
h.z = c
g.q = e
g.u = l
c.r = i
c.z = i
d.r = i
d.z = h
f.q = e
f.u = g
b.q = e
b.u = l
i.r = d
i.z = h
e.q = g
e.u = f
l.q = b
l.u = f
assert c.r.r.r.z.r.txt == "c"