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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

f.u = m
f.t = b
f.q = b
d.u = f
d.s = b
d.q = i
n.q = b
n.t = d
e.z = b
e.r = i
m.y = f
m.p = f
m.q = f
m.u = d
b.v = i
b.y = i
b.u = d
b.p = f
b.w = e
b.t = n
i.t = n
i.o = d
i.w = d
i.u = d
i.r = b
assert m.q.u.p.q.p.txt == "f"