class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: A = None
        self.q: G = None
        self.p: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: E = None
        self.txt = txt

g = A("g")
k = B("k")
h = C("h")
m = D("m")
i = E("i")
b = F("b")
d = G("d")
f = F("f")
e = C("e")

g.o = h
k.r = m
k.p = e
h.q = k
m.y = h
m.x = g
m.p = g
m.q = d
i.t = k
b.s = k
b.t = k
b.r = h
b.u = m
b.p = i
b.y = g
d.u = k
d.q = i
f.s = k
f.t = k
f.r = e
f.u = m
f.p = i
f.y = g
e.q = k
assert h.q.r.x.o.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: A = None
        self.q: G = None
        self.p: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: E = None
        self.txt = txt

g = A("g")
k = B("k")
h = C("h")
m = D("m")
i = E("i")
b = F("b")
d = G("d")
f = F("f")
e = C("e")

g.o = h
k.r = m
k.p = e
h.q = k
m.y = h
m.x = g
m.p = g
m.q = d
i.t = k
b.s = k
b.t = k
b.r = h
b.u = m
b.p = i
b.y = g
d.u = k
d.q = i
f.s = k
f.t = k
f.r = e
f.u = m
f.p = i
f.y = g
e.q = k
assert h.q.r.x.o.q.p.txt == "e"