class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: E = None
        self.u: B = None
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: 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: C = None
        self.y: D = None
        self.q: F = None
        self.w: B = None
        self.t: F = None
        self.txt = txt

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

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

k.p = f
k.q = j
k.u = h
k.o = d
h.s = n
g.u = d
d.q = j
j.r = g
j.y = d
j.q = f
j.w = h
j.t = n
n.s = k
n.y = g
e.s = f
f.s = k
f.y = g
assert g.u.q.r.u.q.y.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: E = None
        self.u: B = None
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: 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: C = None
        self.y: D = None
        self.q: F = None
        self.w: B = None
        self.t: F = None
        self.txt = txt

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

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

k.p = f
k.q = j
k.u = h
k.o = d
h.s = n
g.u = d
d.q = j
j.r = g
j.y = d
j.q = f
j.w = h
j.t = n
n.s = k
n.y = g
e.s = f
f.s = k
f.y = g
assert g.u.q.r.u.q.y.q.t.txt == "n"