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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.r: C = None
        self.v: F = None
        self.s: F = None
        self.x: E = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

d = A("d")
i = B("i")
h = C("h")
l = D("l")
f = E("f")
m = F("m")
b = F("b")

d.u = l
i.y = h
i.p = h
i.r = h
i.v = b
i.s = b
i.x = f
h.q = i
l.w = i
l.z = i
l.s = d
f.r = i
f.v = d
f.w = d
f.s = l
f.z = h
m.y = d
b.y = d
assert f.r.x.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.r: C = None
        self.v: F = None
        self.s: F = None
        self.x: E = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

d = A("d")
i = B("i")
h = C("h")
l = D("l")
f = E("f")
m = F("m")
b = F("b")

d.u = l
i.y = h
i.p = h
i.r = h
i.v = b
i.s = b
i.x = f
h.q = i
l.w = i
l.z = i
l.s = d
f.r = i
f.v = d
f.w = d
f.s = l
f.z = h
m.y = d
b.y = d
assert f.r.x.r.s.txt == "b"