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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: A = None
        self.t: B = None
        self.w: C = None
        self.r: A = None
        self.txt = txt

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

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: A = None
        self.t: B = None
        self.w: C = None
        self.r: A = None
        self.txt = txt

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

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