class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: F = None
        self.s: E = None
        self.p: G = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.z: D = None
        self.q: F = None
        self.w: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: E = None
        self.o: G = None
        self.t: B = None
        self.p: F = None
        self.r: F = None
        self.z: E = None
        self.txt = txt

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.z: D = None
        self.q: F = None
        self.w: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: E = None
        self.o: G = None
        self.t: B = None
        self.p: F = None
        self.r: F = None
        self.z: E = None
        self.txt = txt

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

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

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

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

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