class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: C = None
        self.t: C = None
        self.y: A = None
        self.w: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: D = None
        self.w: D = None
        self.u: B = None
        self.txt = txt

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

j.s = c
c.w = d
m.x = h
m.y = h
h.p = c
h.u = m
h.t = m
h.y = j
h.w = d
f.p = m
f.r = j
f.u = d
d.r = f
d.x = h
d.w = h
d.u = c
assert c.w.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: C = None
        self.t: C = None
        self.y: A = None
        self.w: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: D = None
        self.w: D = None
        self.u: B = None
        self.txt = txt

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

j.s = c
c.w = d
m.x = h
m.y = h
h.p = c
h.u = m
h.t = m
h.y = j
h.w = d
f.p = m
f.r = j
f.u = d
d.r = f
d.x = h
d.w = h
d.u = c
assert c.w.w.p.txt == "c"