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

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

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

h = A("h")
i = B("i")
e = C("e")
d = A("d")
a = A("a")
b = C("b")
m = A("m")

h.r = e
h.q = d
h.w = d
i.w = e
i.o = d
i.z = h
e.x = h
e.y = i
e.w = i
d.r = e
d.q = a
d.w = a
a.r = e
a.q = d
a.w = d
b.x = d
b.y = i
b.w = i
m.r = e
m.q = a
m.w = a
assert m.w.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: A = None
        self.w: A = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
e = C("e")
d = A("d")
a = A("a")
b = C("b")
m = A("m")

h.r = e
h.q = d
h.w = d
i.w = e
i.o = d
i.z = h
e.x = h
e.y = i
e.w = i
d.r = e
d.q = a
d.w = a
a.r = e
a.q = d
a.w = d
b.x = d
b.y = i
b.w = i
m.r = e
m.q = a
m.w = a
assert m.w.r.x.txt == "h"