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

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

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.t: E = None
        self.p: B = None
        self.r: B = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.t: E = None
        self.p: B = None
        self.r: B = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

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