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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

b = A("b")
c = B("c")
k = C("k")
j = D("j")
d = E("d")
i = B("i")
g = D("g")
f = A("f")
h = A("h")
m = C("m")

b.q = g
b.z = k
c.z = m
k.x = d
j.z = i
j.x = k
j.v = g
d.r = g
i.z = k
g.z = i
g.x = m
g.v = j
f.q = j
f.z = k
h.q = g
h.z = k
m.x = d
assert g.x.x.r.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

b = A("b")
c = B("c")
k = C("k")
j = D("j")
d = E("d")
i = B("i")
g = D("g")
f = A("f")
h = A("h")
m = C("m")

b.q = g
b.z = k
c.z = m
k.x = d
j.z = i
j.x = k
j.v = g
d.r = g
i.z = k
g.z = i
g.x = m
g.v = j
f.q = j
f.z = k
h.q = g
h.z = k
m.x = d
assert g.x.x.r.x.x.txt == "d"