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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

c = A("c")
d = B("d")
n = C("n")
h = D("h")
a = E("a")
l = F("l")
f = G("f")
i = C("i")

c.w = a
c.r = i
d.w = a
n.u = i
n.x = c
h.v = a
h.p = c
a.s = d
l.p = a
f.p = i
i.u = n
i.x = c
assert i.x.w.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.r: C = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

c = A("c")
d = B("d")
n = C("n")
h = D("h")
a = E("a")
l = F("l")
f = G("f")
i = C("i")

c.w = a
c.r = i
d.w = a
n.u = i
n.x = c
h.v = a
h.p = c
a.s = d
l.p = a
f.p = i
i.u = n
i.x = c
assert i.x.w.s.w.s.w.txt == "a"