class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

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

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

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