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

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

i = A("i")
d = B("d")
l = C("l")
h = D("h")
m = B("m")
f = C("f")
e = B("e")
c = A("c")
b = C("b")

i.w = h
i.q = c
d.x = i
d.q = e
d.u = m
d.v = h
l.x = i
h.x = l
h.v = m
h.q = c
h.s = i
m.x = i
m.q = d
m.u = d
m.v = h
f.x = c
e.x = c
e.q = d
e.u = m
e.v = h
c.w = h
c.q = i
b.x = c
assert c.q.q.q.q.q.w.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

i = A("i")
d = B("d")
l = C("l")
h = D("h")
m = B("m")
f = C("f")
e = B("e")
c = A("c")
b = C("b")

i.w = h
i.q = c
d.x = i
d.q = e
d.u = m
d.v = h
l.x = i
h.x = l
h.v = m
h.q = c
h.s = i
m.x = i
m.q = d
m.u = d
m.v = h
f.x = c
e.x = c
e.q = d
e.u = m
e.v = h
c.w = h
c.q = i
b.x = c
assert c.q.q.q.q.q.w.q.q.q.txt == "c"