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

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

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

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

f.q = n
f.r = e
m.q = c
m.p = e
m.v = b
n.w = i
i.w = h
a.q = e
a.p = m
a.v = f
e.q = c
e.p = c
e.v = b
b.q = i
b.r = e
h.w = i
c.q = e
c.p = a
c.v = b
d.q = i
d.r = a
assert c.p.q.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: B = None
        self.txt = txt

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

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

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

f.q = n
f.r = e
m.q = c
m.p = e
m.v = b
n.w = i
i.w = h
a.q = e
a.p = m
a.v = f
e.q = c
e.p = c
e.v = b
b.q = i
b.r = e
h.w = i
c.q = e
c.p = a
c.v = b
d.q = i
d.r = a
assert c.p.q.v.r.txt == "e"