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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.q: B = None
        self.o: B = None
        self.r: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: E = None
        self.r: F = None
        self.txt = txt

e = A("e")
d = B("d")
n = C("n")
c = D("c")
f = E("f")
h = F("h")
b = D("b")
g = B("g")
a = F("a")

e.s = b
d.o = g
n.s = f
n.q = e
n.o = e
c.y = e
c.q = b
c.x = a
f.s = e
f.t = d
f.q = d
f.o = g
f.r = h
h.y = g
h.q = f
h.r = a
b.y = e
b.q = c
b.x = h
g.o = d
a.y = g
a.q = f
a.r = h
assert g.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: B = None
        self.q: B = None
        self.o: B = None
        self.r: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: E = None
        self.r: F = None
        self.txt = txt

e = A("e")
d = B("d")
n = C("n")
c = D("c")
f = E("f")
h = F("h")
b = D("b")
g = B("g")
a = F("a")

e.s = b
d.o = g
n.s = f
n.q = e
n.o = e
c.y = e
c.q = b
c.x = a
f.s = e
f.t = d
f.q = d
f.o = g
f.r = h
h.y = g
h.q = f
h.r = a
b.y = e
b.q = c
b.x = h
g.o = d
a.y = g
a.q = f
a.r = h
assert g.o.o.o.txt == "d"