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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: C = None
        self.z: B = None
        self.txt = txt

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

k.p = e
k.u = n
k.q = f
g.s = e
g.u = e
g.p = e
g.t = n
g.w = d
f.w = d
f.p = d
n.s = f
n.r = d
e.x = f
d.q = g
d.z = g
d.v = f
assert g.w.v.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.u: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: C = None
        self.z: B = None
        self.txt = txt

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

k.p = e
k.u = n
k.q = f
g.s = e
g.u = e
g.p = e
g.t = n
g.w = d
f.w = d
f.p = d
n.s = f
n.r = d
e.x = f
d.q = g
d.z = g
d.v = f
assert g.w.v.p.z.txt == "g"