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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.s: A = None
        self.txt = txt

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

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.s: A = None
        self.txt = txt

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

j.w = n
j.p = n
m.p = j
h.v = n
h.z = n
h.p = a
h.w = j
h.r = j
h.x = m
n.r = h
a.q = j
a.v = h
i.v = m
i.u = m
i.s = j
assert i.v.p.w.r.z.r.txt == "h"