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

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

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

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

k = A("k")
d = B("d")
h = C("h")
c = D("c")
e = D("e")
i = B("i")
b = A("b")
g = B("g")

k.r = i
k.w = b
k.u = d
d.q = e
d.z = e
d.u = b
h.q = i
h.r = i
h.p = e
h.w = b
c.w = h
e.w = h
i.q = c
i.u = k
i.z = e
b.r = d
b.u = d
b.w = k
g.q = e
g.z = e
g.u = k
assert i.q.w.p.w.q.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: A = None
        self.u: B = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
h = C("h")
c = D("c")
e = D("e")
i = B("i")
b = A("b")
g = B("g")

k.r = i
k.w = b
k.u = d
d.q = e
d.z = e
d.u = b
h.q = i
h.r = i
h.p = e
h.w = b
c.w = h
e.w = h
i.q = c
i.u = k
i.z = e
b.r = d
b.u = d
b.w = k
g.q = e
g.z = e
g.u = k
assert i.q.w.p.w.q.q.w.w.txt == "b"