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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: A = None
        self.w: C = None
        self.u: F = None
        self.r: E = None
        self.s: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: D = None
        self.y: 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.q: D = None
        self.p: B = None
        self.s: C = None
        self.txt = txt

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

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

m.u = h
b.v = h
b.s = h
b.p = m
b.w = k
b.u = g
b.r = e
k.p = m
k.s = h
k.y = h
h.w = m
e.q = h
e.p = b
e.s = k
g.z = e
assert m.u.w.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: A = None
        self.w: C = None
        self.u: F = None
        self.r: E = None
        self.s: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: D = None
        self.y: 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.q: D = None
        self.p: B = None
        self.s: C = None
        self.txt = txt

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

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

m.u = h
b.v = h
b.s = h
b.p = m
b.w = k
b.u = g
b.r = e
k.p = m
k.s = h
k.y = h
h.w = m
e.q = h
e.p = b
e.s = k
g.z = e
assert m.u.w.u.w.u.txt == "h"