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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

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

h.z = c
h.w = a
h.q = a
g.v = c
g.s = c
g.u = n
g.y = m
n.s = h
c.v = b
m.v = j
m.r = n
m.y = n
m.u = g
m.x = c
j.u = g
a.s = h
b.v = c
assert a.s.w.s.z.v.v.txt == "c"