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

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

class C:
    def __init__(self, txt: str):
        self.u: F = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.q: A = None
        self.s: E = None
        self.y: C = None
        self.p: F = None
        self.o: C = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: C = None
        self.o: F = None
        self.x: F = None
        self.z: D = None
        self.t: D = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.u: F = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.q: A = None
        self.s: E = None
        self.y: C = None
        self.p: F = None
        self.o: C = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: C = None
        self.o: F = None
        self.x: F = None
        self.z: D = None
        self.t: D = None
        self.txt = txt

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

h.p = g
h.u = g
f.r = b
f.x = a
g.u = k
g.x = b
b.r = f
b.z = g
b.y = g
b.o = g
b.q = h
b.s = c
b.p = k
c.x = k
c.o = k
k.t = f
a.p = h
a.q = g
a.o = k
a.x = k
a.z = b
a.t = b
assert h.u.x.o.txt == "g"