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

class B:
    def __init__(self, txt: str):
        self.t: G = None
        self.s: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: F = None
        self.w: A = None
        self.v: F = None
        self.o: D = None
        self.s: F = None
        self.p: A = None
        self.txt = txt

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

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

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

k.t = b
f.t = d
f.s = k
m.r = b
m.z = b
m.p = h
m.s = k
m.t = n
m.o = f
n.p = m
b.r = n
b.o = n
b.x = h
b.v = h
b.s = h
b.w = k
b.p = k
h.v = k
h.o = m
d.r = f
assert k.t.w.t.r.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: G = None
        self.s: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: F = None
        self.w: A = None
        self.v: F = None
        self.o: D = None
        self.s: F = None
        self.p: A = None
        self.txt = txt

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

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

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

k.t = b
f.t = d
f.s = k
m.r = b
m.z = b
m.p = h
m.s = k
m.t = n
m.o = f
n.p = m
b.r = n
b.o = n
b.x = h
b.v = h
b.s = h
b.w = k
b.p = k
h.v = k
h.o = m
d.r = f
assert k.t.w.t.r.p.z.txt == "b"