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

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

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

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

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

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

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

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

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

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

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

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

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

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

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