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

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

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.z: B = None
        self.s: E = None
        self.r: B = None
        self.p: E = None
        self.txt = txt

k = A("k")
b = B("b")
m = C("m")
n = D("n")
a = E("a")
h = F("h")
j = E("j")
i = A("i")

k.w = h
b.y = k
m.p = h
n.r = j
n.w = a
a.q = b
a.t = h
h.x = m
h.v = b
h.z = b
h.r = b
h.s = a
h.p = a
j.q = b
j.t = h
i.w = h
assert n.r.q.y.w.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.z: B = None
        self.s: E = None
        self.r: B = None
        self.p: E = None
        self.txt = txt

k = A("k")
b = B("b")
m = C("m")
n = D("n")
a = E("a")
h = F("h")
j = E("j")
i = A("i")

k.w = h
b.y = k
m.p = h
n.r = j
n.w = a
a.q = b
a.t = h
h.x = m
h.v = b
h.z = b
h.r = b
h.s = a
h.p = a
j.q = b
j.t = h
i.w = h
assert n.r.q.y.w.x.p.txt == "h"