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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.r: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
n = C("n")
g = B("g")
a = C("a")
i = C("i")
d = A("d")
m = B("m")
l = A("l")

b.r = i
b.s = m
b.y = d
c.y = a
c.t = i
c.r = g
n.z = l
n.w = c
g.y = i
g.t = i
g.r = c
a.z = b
a.w = g
i.z = d
i.w = g
d.r = a
d.s = m
d.y = b
m.y = i
m.t = a
m.r = c
l.r = a
l.s = c
l.y = d
assert g.r.t.z.y.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: B = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.r: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
n = C("n")
g = B("g")
a = C("a")
i = C("i")
d = A("d")
m = B("m")
l = A("l")

b.r = i
b.s = m
b.y = d
c.y = a
c.t = i
c.r = g
n.z = l
n.w = c
g.y = i
g.t = i
g.r = c
a.z = b
a.w = g
i.z = d
i.w = g
d.r = a
d.s = m
d.y = b
m.y = i
m.t = a
m.r = c
l.r = a
l.s = c
l.y = d
assert g.r.t.z.y.r.z.r.txt == "a"