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

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

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

i = A("i")
g = B("g")
j = C("j")
h = C("h")
b = A("b")
m = B("m")
d = A("d")
c = C("c")

i.r = m
i.y = m
g.t = m
g.y = m
g.u = c
j.u = i
j.w = g
j.z = c
h.u = i
h.w = g
h.z = j
b.r = m
b.y = m
m.t = g
m.y = g
m.u = h
d.r = m
d.y = g
c.u = b
c.w = g
c.z = h
assert j.z.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: B = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
j = C("j")
h = C("h")
b = A("b")
m = B("m")
d = A("d")
c = C("c")

i.r = m
i.y = m
g.t = m
g.y = m
g.u = c
j.u = i
j.w = g
j.z = c
h.u = i
h.w = g
h.z = j
b.r = m
b.y = m
m.t = g
m.y = g
m.u = h
d.r = m
d.y = g
c.u = b
c.w = g
c.z = h
assert j.z.w.u.w.txt == "g"