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

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.z: F = None
        self.o: G = None
        self.p: D = None
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: A = None
        self.r: A = None
        self.q: G = None
        self.v: G = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: G = None
        self.x: C = None
        self.s: C = None
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

d.p = i
d.t = a
h.x = f
h.z = f
h.y = f
h.o = i
h.p = k
n.w = k
n.s = d
n.r = d
n.q = i
n.v = i
k.q = f
a.r = d
a.p = f
f.y = k
f.u = i
f.x = n
f.s = n
f.w = n
f.z = h
i.p = f
i.u = f
assert k.q.w.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: G = None
        self.t: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.z: F = None
        self.o: G = None
        self.p: D = None
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: A = None
        self.r: A = None
        self.q: G = None
        self.v: G = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: G = None
        self.x: C = None
        self.s: C = None
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

d.p = i
d.t = a
h.x = f
h.z = f
h.y = f
h.o = i
h.p = k
n.w = k
n.s = d
n.r = d
n.q = i
n.v = i
k.q = f
a.r = d
a.p = f
f.y = k
f.u = i
f.x = n
f.s = n
f.w = n
f.z = h
i.p = f
i.u = f
assert k.q.w.q.p.txt == "f"