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

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: E = None
        self.w: F = None
        self.txt = txt

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

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

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

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

a.s = c
a.r = g
d.r = h
d.v = h
d.y = f
d.w = c
h.v = m
h.u = j
h.w = g
c.v = a
j.u = a
j.y = h
g.z = d
f.u = a
f.y = m
m.v = h
m.u = f
m.w = g
assert d.r.w.z.w.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: E = None
        self.w: F = None
        self.txt = txt

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

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

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

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

a.s = c
a.r = g
d.r = h
d.v = h
d.y = f
d.w = c
h.v = m
h.u = j
h.w = g
c.v = a
j.u = a
j.y = h
g.z = d
f.u = a
f.y = m
m.v = h
m.u = f
m.w = g
assert d.r.w.z.w.v.r.txt == "g"