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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: D = None
        self.x: D = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
l = C("l")
i = D("i")
m = E("m")
h = F("h")
n = G("n")
d = G("d")

e.p = i
e.v = i
e.y = h
e.q = c
e.t = m
c.q = i
c.z = i
c.x = i
l.t = h
i.p = e
m.q = l
h.x = e
n.t = l
n.p = h
n.w = e
d.t = l
d.p = h
d.w = e
assert h.x.y.x.q.x.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: F = None
        self.q: B = None
        self.t: E = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: D = None
        self.x: D = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
l = C("l")
i = D("i")
m = E("m")
h = F("h")
n = G("n")
d = G("d")

e.p = i
e.v = i
e.y = h
e.q = c
e.t = m
c.q = i
c.z = i
c.x = i
l.t = h
i.p = e
m.q = l
h.x = e
n.t = l
n.p = h
n.w = e
d.t = l
d.p = h
d.w = e
assert h.x.y.x.q.x.p.y.txt == "h"