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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: B = None
        self.p: B = None
        self.txt = txt

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

c = A("c")
i = B("i")
e = C("e")
h = C("h")
l = B("l")
a = B("a")
b = B("b")
m = A("m")
g = A("g")
j = B("j")

c.r = l
c.z = a
c.q = g
i.q = e
i.o = j
i.p = l
e.r = h
e.x = a
e.o = i
h.r = e
h.x = i
h.o = a
l.q = h
l.o = i
l.p = a
a.q = h
a.o = i
a.p = j
b.q = e
b.o = a
b.p = l
m.r = j
m.z = l
m.q = c
g.r = a
g.z = b
g.q = c
j.q = e
j.o = l
j.p = b
assert m.r.o.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: B = None
        self.p: B = None
        self.txt = txt

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

c = A("c")
i = B("i")
e = C("e")
h = C("h")
l = B("l")
a = B("a")
b = B("b")
m = A("m")
g = A("g")
j = B("j")

c.r = l
c.z = a
c.q = g
i.q = e
i.o = j
i.p = l
e.r = h
e.x = a
e.o = i
h.r = e
h.x = i
h.o = a
l.q = h
l.o = i
l.p = a
a.q = h
a.o = i
a.p = j
b.q = e
b.o = a
b.p = l
m.r = j
m.z = l
m.q = c
g.r = a
g.z = b
g.q = c
j.q = e
j.o = l
j.p = b
assert m.r.o.o.p.txt == "l"