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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: E = None
        self.t: E = None
        self.u: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.v: F = None
        self.r: F = None
        self.y: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: A = None
        self.w: A = None
        self.p: E = None
        self.x: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: F = None
        self.v: D = None
        self.s: B = None
        self.u: D = None
        self.y: B = None
        self.txt = txt

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

g = A("g")
m = B("m")
h = C("h")
f = D("f")
a = E("a")
b = F("b")
k = A("k")
d = C("d")

g.q = a
m.x = g
m.q = a
m.t = a
m.u = b
h.s = b
h.v = b
h.r = b
h.y = a
f.y = k
f.s = k
f.w = k
f.x = k
f.p = a
a.w = b
a.v = f
a.u = f
a.s = m
a.y = m
b.w = d
b.r = f
b.v = g
k.q = a
d.s = b
d.v = b
d.r = b
d.y = a
assert f.p.w.v.q.w.w.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: E = None
        self.t: E = None
        self.u: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.v: F = None
        self.r: F = None
        self.y: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: A = None
        self.w: A = None
        self.p: E = None
        self.x: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: F = None
        self.v: D = None
        self.s: B = None
        self.u: D = None
        self.y: B = None
        self.txt = txt

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

g = A("g")
m = B("m")
h = C("h")
f = D("f")
a = E("a")
b = F("b")
k = A("k")
d = C("d")

g.q = a
m.x = g
m.q = a
m.t = a
m.u = b
h.s = b
h.v = b
h.r = b
h.y = a
f.y = k
f.s = k
f.w = k
f.x = k
f.p = a
a.w = b
a.v = f
a.u = f
a.s = m
a.y = m
b.w = d
b.r = f
b.v = g
k.q = a
d.s = b
d.v = b
d.r = b
d.y = a
assert f.p.w.v.q.w.w.s.r.txt == "f"