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

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

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

i = A("i")
l = B("l")
j = C("j")
d = B("d")
k = A("k")
g = A("g")
m = B("m")
h = C("h")

i.r = d
i.s = l
l.x = g
j.z = h
j.w = l
d.x = k
k.r = d
k.s = m
g.r = m
g.s = m
m.x = g
h.z = j
h.w = l
assert j.w.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: B = None
        self.txt = txt

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

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

i = A("i")
l = B("l")
j = C("j")
d = B("d")
k = A("k")
g = A("g")
m = B("m")
h = C("h")

i.r = d
i.s = l
l.x = g
j.z = h
j.w = l
d.x = k
k.r = d
k.s = m
g.r = m
g.s = m
m.x = g
h.z = j
h.w = l
assert j.w.x.r.txt == "m"