class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.s: F = None
        self.w: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: C = None
        self.x: C = None
        self.y: B = None
        self.r: C = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: F = None
        self.w: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: C = None
        self.x: C = None
        self.y: B = None
        self.r: C = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: F = None
        self.w: C = None
        self.txt = txt

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

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