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

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

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

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

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

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

d = A("d")
a = B("a")
n = C("n")
c = D("c")
i = E("i")
h = F("h")
j = F("j")
k = F("k")

d.s = i
d.z = j
a.z = c
n.p = i
n.x = i
n.u = d
n.w = h
c.r = n
i.y = c
i.r = n
h.z = d
j.z = d
k.z = d
assert j.z.s.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.z: F = None
        self.txt = txt

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

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

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

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

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

d = A("d")
a = B("a")
n = C("n")
c = D("c")
i = E("i")
h = F("h")
j = F("j")
k = F("k")

d.s = i
d.z = j
a.z = c
n.p = i
n.x = i
n.u = d
n.w = h
c.r = n
i.y = c
i.r = n
h.z = d
j.z = d
k.z = d
assert j.z.s.r.u.txt == "d"