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

class B:
    def __init__(self, txt: str):
        self.q: G = None
        self.x: C = None
        self.w: D = None
        self.t: D = None
        self.u: D = None
        self.o: G = None
        self.txt = txt

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

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

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

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

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

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

k.p = f
e.q = b
e.o = b
e.x = d
e.w = h
e.t = h
e.u = h
d.q = g
h.u = k
g.w = d
f.t = d
b.o = k
b.p = g
assert k.p.t.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: G = None
        self.x: C = None
        self.w: D = None
        self.t: D = None
        self.u: D = None
        self.o: G = None
        self.txt = txt

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

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

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

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

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

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

k.p = f
e.q = b
e.o = b
e.x = d
e.w = h
e.t = h
e.u = h
d.q = g
h.u = k
g.w = d
f.t = d
b.o = k
b.p = g
assert k.p.t.q.w.q.txt == "g"