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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: D = None
        self.t: A = None
        self.s: B = None
        self.o: B = None
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: F = None
        self.z: A = None
        self.s: C = None
        self.u: F = None
        self.t: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: F = None
        self.z: D = None
        self.x: G = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: D = None
        self.t: A = None
        self.s: B = None
        self.o: B = None
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: F = None
        self.z: A = None
        self.s: C = None
        self.u: F = None
        self.t: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: F = None
        self.z: D = None
        self.x: G = None
        self.s: C = None
        self.txt = txt

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

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

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

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