class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.z: B = None
        self.q: F = None
        self.txt = txt

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

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.z: B = None
        self.q: F = None
        self.txt = txt

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

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

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

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