class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.s: D = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: B = None
        self.t: D = None
        self.txt = txt

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

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

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

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

h.p = l
h.s = n
h.y = f
h.r = f
i.w = a
i.z = l
i.u = l
c.w = i
c.q = i
c.t = n
n.q = a
a.r = l
l.w = i
l.p = a
l.t = c
j.q = a
f.p = l
f.s = n
f.y = h
f.r = h
assert f.s.q.r.w.u.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.s: D = None
        self.y: A = None
        self.r: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: B = None
        self.t: D = None
        self.txt = txt

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

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

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

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

h.p = l
h.s = n
h.y = f
h.r = f
i.w = a
i.z = l
i.u = l
c.w = i
c.q = i
c.t = n
n.q = a
a.r = l
l.w = i
l.p = a
l.t = c
j.q = a
f.p = l
f.s = n
f.y = h
f.r = h
assert f.s.q.r.w.u.p.r.p.txt == "a"