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

class B:
    def __init__(self, txt: str):
        self.r: F = None
        self.s: G = None
        self.x: D = None
        self.t: G = None
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

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

k = A("k")
f = B("f")
c = C("c")
b = D("b")
d = E("d")
m = F("m")
j = G("j")

k.x = m
f.r = m
f.s = j
f.t = j
f.x = b
f.z = c
f.p = c
c.t = d
c.y = f
c.q = k
b.w = c
d.z = c
m.v = k
m.u = f
m.o = f
j.s = k
j.v = c
j.p = m
assert c.t.z.y.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: F = None
        self.s: G = None
        self.x: D = None
        self.t: G = None
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

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

k = A("k")
f = B("f")
c = C("c")
b = D("b")
d = E("d")
m = F("m")
j = G("j")

k.x = m
f.r = m
f.s = j
f.t = j
f.x = b
f.z = c
f.p = c
c.t = d
c.y = f
c.q = k
b.w = c
d.z = c
m.v = k
m.u = f
m.o = f
j.s = k
j.v = c
j.p = m
assert c.t.z.y.z.q.txt == "k"