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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: A = None
        self.w: D = None
        self.z: A = None
        self.t: G = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.o: G = None
        self.z: D = None
        self.y: D = None
        self.s: D = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: A = None
        self.w: D = None
        self.z: A = None
        self.t: G = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.o: G = None
        self.z: D = None
        self.y: D = None
        self.s: D = None
        self.txt = txt

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

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

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

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