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

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: C = None
        self.p: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: B = None
        self.s: D = None
        self.p: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: A = None
        self.r: B = None
        self.v: C = None
        self.txt = txt

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

d.w = h
b.q = e
b.w = h
b.p = c
m.v = c
m.x = c
m.r = c
m.t = k
m.q = g
g.w = d
c.z = b
c.o = e
c.p = e
c.s = g
k.t = m
k.x = d
k.r = b
k.v = h
e.q = b
e.w = h
e.p = c
h.v = c
h.x = c
h.r = c
h.t = k
h.q = g
assert d.w.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: C = None
        self.p: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: B = None
        self.s: D = None
        self.p: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: A = None
        self.r: B = None
        self.v: C = None
        self.txt = txt

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

d.w = h
b.q = e
b.w = h
b.p = c
m.v = c
m.x = c
m.r = c
m.t = k
m.q = g
g.w = d
c.z = b
c.o = e
c.p = e
c.s = g
k.t = m
k.x = d
k.r = b
k.v = h
e.q = b
e.w = h
e.p = c
h.v = c
h.x = c
h.r = c
h.t = k
h.q = g
assert d.w.q.w.w.txt == "h"