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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: D = None
        self.x: F = None
        self.r: A = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
m = C("m")
h = D("h")
f = E("f")
b = F("b")
c = B("c")

g.o = c
g.w = h
i.w = m
i.q = h
i.x = b
i.r = g
m.u = f
m.w = i
h.x = b
f.t = b
f.y = b
f.u = c
b.q = i
c.w = m
c.q = h
c.x = b
c.r = g
assert f.u.x.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: D = None
        self.x: F = None
        self.r: A = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
m = C("m")
h = D("h")
f = E("f")
b = F("b")
c = B("c")

g.o = c
g.w = h
i.w = m
i.q = h
i.x = b
i.r = g
m.u = f
m.w = i
h.x = b
f.t = b
f.y = b
f.u = c
b.q = i
c.w = m
c.q = h
c.x = b
c.r = g
assert f.u.x.q.w.w.txt == "i"