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

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

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

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

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

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

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

a.o = g
a.w = f
f.w = m
j.x = m
j.v = m
j.w = f
m.t = j
m.w = g
m.u = h
h.u = j
h.q = a
g.v = m
g.x = h
assert h.u.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: F = None
        self.w: B = None
        self.txt = txt

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

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

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

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

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

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

a.o = g
a.w = f
f.w = m
j.x = m
j.v = m
j.w = f
m.t = j
m.w = g
m.u = h
h.u = j
h.q = a
g.v = m
g.x = h
assert h.u.w.w.txt == "m"