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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: G = None
        self.w: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: G = None
        self.w: E = None
        self.txt = txt

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

l = A("l")
m = B("m")
e = C("e")
f = D("f")
n = E("n")
h = F("h")
i = G("i")

l.u = h
l.z = e
l.p = e
l.w = m
m.x = n
m.s = l
e.w = n
f.u = l
n.u = i
n.w = h
h.p = i
h.w = n
i.x = f
assert e.w.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: C = None
        self.w: B = None
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: G = None
        self.w: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: G = None
        self.w: E = None
        self.txt = txt

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

l = A("l")
m = B("m")
e = C("e")
f = D("f")
n = E("n")
h = F("h")
i = G("i")

l.u = h
l.z = e
l.p = e
l.w = m
m.x = n
m.s = l
e.w = n
f.u = l
n.u = i
n.w = h
h.p = i
h.w = n
i.x = f
assert e.w.u.x.u.txt == "l"