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

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

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

k = A("k")
c = B("c")
h = C("h")
g = C("g")
f = B("f")
e = A("e")
l = C("l")
i = C("i")
a = A("a")

k.q = c
k.w = e
k.r = f
c.o = e
c.v = e
h.q = k
h.r = l
h.p = c
g.q = a
g.r = i
g.p = f
f.o = a
f.v = e
e.q = c
e.w = k
e.r = f
l.q = a
l.r = g
l.p = f
i.q = e
i.r = g
i.p = c
a.q = f
a.w = k
a.r = c
assert a.q.v.r.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: A = None
        self.r: B = None
        self.txt = txt

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

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

k = A("k")
c = B("c")
h = C("h")
g = C("g")
f = B("f")
e = A("e")
l = C("l")
i = C("i")
a = A("a")

k.q = c
k.w = e
k.r = f
c.o = e
c.v = e
h.q = k
h.r = l
h.p = c
g.q = a
g.r = i
g.p = f
f.o = a
f.v = e
e.q = c
e.w = k
e.r = f
l.q = a
l.r = g
l.p = f
i.q = e
i.r = g
i.p = c
a.q = f
a.w = k
a.r = c
assert a.q.v.r.v.q.txt == "c"