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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.y: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.y: B = None
        self.w: D = None
        self.txt = txt

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

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

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