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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: A = None
        self.s: D = None
        self.q: D = None
        self.txt = txt

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

d = A("d")
e = B("e")
f = C("f")
g = D("g")
k = E("k")
h = F("h")

d.u = h
e.w = g
e.y = k
e.s = h
e.x = h
e.u = h
f.o = g
f.x = k
f.r = d
g.y = k
g.q = k
k.o = e
k.y = d
k.s = g
k.q = g
h.z = f
assert e.s.z.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: A = None
        self.s: D = None
        self.q: D = None
        self.txt = txt

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

d = A("d")
e = B("e")
f = C("f")
g = D("g")
k = E("k")
h = F("h")

d.u = h
e.w = g
e.y = k
e.s = h
e.x = h
e.u = h
f.o = g
f.x = k
f.r = d
g.y = k
g.q = k
k.o = e
k.y = d
k.s = g
k.q = g
h.z = f
assert e.s.z.r.u.txt == "h"